--------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  D:\Dropbox\zworking\r-patent\paper-trends\replication\patent-spatial-replication.log
  log type:  text
 opened on:  28 Oct 2021, 07:59:33

.  * William Kerr, TGG;
. * Core RP2 graphics and tables;
. * Combines patents working file and ML sw code in as inputs;
. * Working file is transferred with data;
. * 2 appendix figures produced in R;
. clear all;

.  set more off;

. /*********************************;
> *** Baseline Prep             ***;
> *********************************;
> 
> * Prep AI data;
> use doc_id predict50_any_ai flag_patent 
>     if flag_patent==1 using ./data-ai/ai_model_predictions, clear;
> ren doc_id patent_number; ren predict50_any_ai software_ai; drop flag_patent;
> sort patent_number; save ./temp/patent-ai, replace;
> 
> * Load patent data;
> use patent_number invdom msa1 utility ayear patent_kind domshare software univ ind gov individual 
>     nber_cat1 uspc0 uspc1 gyear ass_id1         
>     dENG dCHN dEUR dHIS dHIN dJAP dKOR dRUS dVNM
>     num_claims backward forward fw_selfcite originality generality 
>     if utility==1 & (domshare>0 & domshare!=.) & (ayear>=1975 & ayear<=2019) 
>        & (nber_cat1>=1 & nber_cat<=6) & software!=. & dENG!=.
>     using ./data-YE20/patents_working, clear;
> drop domshare utility patent_kind;
> sum;
> 
> * Merge software and summarize designation;
> ren software software_bh;
> sort patent_number; merge patent_number using ./data-YE20/extra/alt_software;
> tab _m; drop if _m==2; drop _m; ren software software_gv;
> sort patent_number; merge patent_number using ./data-YE20/extra/ml_software; 
> tab _m; drop if _m==2; drop _m;
> sort patent_number; merge patent_number using ./temp/patent-ai; 
> tab _m; drop if _m==2; drop _m; erase ./temp/patent-ai.dta;
> sum software_bh software_gv software_ml software_ai; 
> sum software_bh software_gv software_ml software_ai if software_ai==1; 
> pwcorr software_bh software_gv software_ml software_ai; 
> 
> * Generate city groups and periods;
> codebook msa1; ren msa1 msa; replace msa=9999 if msa==.;
> gen cluster=3;
> * SF, BOS, SEA, SD, DEN, AUS;
> for any 7362 1122 7602 7320 2082 640: replace cluster=1 if msa==X;
> * NY, LA, CHI, PHL, DET ... (DC, DAL, HOU);
> for any 5602 4472 1602 6162 2162: replace cluster=2 if msa==X;
> replace cluster=4 if msa==. | msa==9999;
> codebook msa if cluster==3;
> gen period=1975;
> for any 1980 1985 1990 1995 2000 2005 2010 2015: replace period=X if ayear>=X; 
> compress;
> save patent-spatial-final1, replace;
> */
> 
> *********************************;
. *** Core Bessen-Hunt Results  ***;
. *********************************;
. use patent-spatial-final1, clear;

. drop gyear ayear num_claims backward forward fw_selfcite originality generality dENG-dVNM uspc*;

. * Organize patents and institutions;
. gen Tcttot=1;

.  gen Tctsw=software_bh;

.  gen Tctnsw=1-software_bh;

. for any cttot ctsw ctnsw: gen IX=TX if ind==1 \ gen UX=TX if univ==1 \ gen GX=TX if gov==1 \ gen NX=TX if (ind==0 & gov==0 & univ==0
> );

->  gen Icttot=Tcttot if ind==1
(681,131 missing values generated)

->  gen Ucttot=Tcttot if univ==1
(3,362,226 missing values generated)

->  gen Gcttot=Tcttot if gov==1
(3,458,327 missing values generated)

->  gen Ncttot=Tcttot if (ind==0 & gov==0 & univ==0)
(2,976,786 missing values generated)

->  gen Ictsw=Tctsw if ind==1
(681,131 missing values generated)

->  gen Uctsw=Tctsw if univ==1
(3,362,226 missing values generated)

->  gen Gctsw=Tctsw if gov==1
(3,458,327 missing values generated)

->  gen Nctsw=Tctsw if (ind==0 & gov==0 & univ==0)
(2,976,786 missing values generated)

->  gen Ictnsw=Tctnsw if ind==1
(681,131 missing values generated)

->  gen Uctnsw=Tctnsw if univ==1
(3,362,226 missing values generated)

->  gen Gctnsw=Tctnsw if gov==1
(3,458,327 missing values generated)

->  gen Nctnsw=Tctnsw if (ind==0 & gov==0 & univ==0)
(2,976,786 missing values generated)

. for any cttot ctsw ctnsw: gen C1X=TX if (nber_cat==2 | nber_cat==4) \ gen C2X=TX if (nber_cat==1 | nber_cat==3) \ gen C3X=TX if (nbe
> r_cat==5 | nber_cat==6);

->  gen C1cttot=Tcttot if (nber_cat==2 | nber_cat==4)
(1,934,914 missing values generated)

->  gen C2cttot=Tcttot if (nber_cat==1 | nber_cat==3)
(2,627,038 missing values generated)

->  gen C3cttot=Tcttot if (nber_cat==5 | nber_cat==6)
(2,434,464 missing values generated)

->  gen C1ctsw=Tctsw if (nber_cat==2 | nber_cat==4)
(1,934,914 missing values generated)

->  gen C2ctsw=Tctsw if (nber_cat==1 | nber_cat==3)
(2,627,038 missing values generated)

->  gen C3ctsw=Tctsw if (nber_cat==5 | nber_cat==6)
(2,434,464 missing values generated)

->  gen C1ctnsw=Tctnsw if (nber_cat==2 | nber_cat==4)
(1,934,914 missing values generated)

->  gen C2ctnsw=Tctnsw if (nber_cat==1 | nber_cat==3)
(2,627,038 missing values generated)

->  gen C3ctnsw=Tctnsw if (nber_cat==5 | nber_cat==6)
(2,434,464 missing values generated)

. for num 1/6: gen ZXctsw=Tctsw if nber_cat==X \ gen ZXctnsw=Tctnsw if nber_cat==X;

->  gen Z1ctsw=Tctsw if nber_cat==1
(3,069,381 missing values generated)

->  gen Z1ctnsw=Tctnsw if nber_cat==1
(3,069,381 missing values generated)

->  gen Z2ctsw=Tctsw if nber_cat==2
(2,534,783 missing values generated)

->  gen Z2ctnsw=Tctnsw if nber_cat==2
(2,534,783 missing values generated)

->  gen Z3ctsw=Tctsw if nber_cat==3
(3,055,865 missing values generated)

->  gen Z3ctnsw=Tctnsw if nber_cat==3
(3,055,865 missing values generated)

->  gen Z4ctsw=Tctsw if nber_cat==4
(2,898,339 missing values generated)

->  gen Z4ctnsw=Tctnsw if nber_cat==4
(2,898,339 missing values generated)

->  gen Z5ctsw=Tctsw if nber_cat==5
(3,017,727 missing values generated)

->  gen Z5ctnsw=Tctnsw if nber_cat==5
(3,017,727 missing values generated)

->  gen Z6ctsw=Tctsw if nber_cat==6
(2,914,945 missing values generated)

->  gen Z6ctnsw=Tctnsw if nber_cat==6
(2,914,945 missing values generated)

. * Collapse on MSA-period cells and merge population data;
. * Prepare a zero-valued observation for 7000 in 1980;
. * Fix pop min for early years of 380 (Anchorage AK) and 3320 (Honolulu HI);
. collapse (sum) T* I* U* G* N* C* Z* (mean) cluster, by(msa period) fast;

. sort msa period;

.  merge msa period using period_population_msa;
(note: you are using old merge syntax; see [D] merge for new syntax)

. tab _m;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |          8        0.32        0.32
          2 |          1        0.04        0.35
          3 |      2,529       99.65      100.00
------------+-----------------------------------
      Total |      2,538      100.00

.  table msa _m if _m!=3;

----------------------
          |   _merge  
      msa |    1     2
----------+-----------
      380 |    3      
     3320 |    5      
     7000 |          1
----------------------

.  ren pop pop;

.  for var T* I* U* G* N* C* Z*: replace X=0 if _m==2;

->  replace Tcttot=0 if _m==2
(1 real change made)

->  replace Tctsw=0 if _m==2
(1 real change made)

->  replace Tctnsw=0 if _m==2
(1 real change made)

->  replace Icttot=0 if _m==2
(1 real change made)

->  replace Ictsw=0 if _m==2
(1 real change made)

->  replace Ictnsw=0 if _m==2
(1 real change made)

->  replace Ucttot=0 if _m==2
(1 real change made)

->  replace Uctsw=0 if _m==2
(1 real change made)

->  replace Uctnsw=0 if _m==2
(1 real change made)

->  replace Gcttot=0 if _m==2
(1 real change made)

->  replace Gctsw=0 if _m==2
(1 real change made)

->  replace Gctnsw=0 if _m==2
(1 real change made)

->  replace Ncttot=0 if _m==2
(1 real change made)

->  replace Nctsw=0 if _m==2
(1 real change made)

->  replace Nctnsw=0 if _m==2
(1 real change made)

->  replace C1cttot=0 if _m==2
(1 real change made)

->  replace C2cttot=0 if _m==2
(1 real change made)

->  replace C3cttot=0 if _m==2
(1 real change made)

->  replace C1ctsw=0 if _m==2
(1 real change made)

->  replace C2ctsw=0 if _m==2
(1 real change made)

->  replace C3ctsw=0 if _m==2
(1 real change made)

->  replace C1ctnsw=0 if _m==2
(1 real change made)

->  replace C2ctnsw=0 if _m==2
(1 real change made)

->  replace C3ctnsw=0 if _m==2
(1 real change made)

->  replace Z1ctsw=0 if _m==2
(1 real change made)

->  replace Z1ctnsw=0 if _m==2
(1 real change made)

->  replace Z2ctsw=0 if _m==2
(1 real change made)

->  replace Z2ctnsw=0 if _m==2
(1 real change made)

->  replace Z3ctsw=0 if _m==2
(1 real change made)

->  replace Z3ctnsw=0 if _m==2
(1 real change made)

->  replace Z4ctsw=0 if _m==2
(1 real change made)

->  replace Z4ctnsw=0 if _m==2
(1 real change made)

->  replace Z5ctsw=0 if _m==2
(1 real change made)

->  replace Z5ctnsw=0 if _m==2
(1 real change made)

->  replace Z6ctsw=0 if _m==2
(1 real change made)

->  replace Z6ctnsw=0 if _m==2
(1 real change made)

. egen temp1=min(pop), by(msa);

.  replace pop=temp1 if _m==1;
(8 real changes made)

.  drop _m temp1;

. * Generate HHI and EG components and collapse;
. for var T*: gen tabX1=X if cluster==1 \ gen tabX2=X if cluster==2 \ gen tabX3=X if cluster==3 \ gen tabX4=X if cluster==4;

->  gen tabTcttot1=Tcttot if cluster==1
(2,484 missing values generated)

->  gen tabTcttot2=Tcttot if cluster==2
(2,493 missing values generated)

->  gen tabTcttot3=Tcttot if cluster==3
(109 missing values generated)

->  gen tabTcttot4=Tcttot if cluster==4
(2,529 missing values generated)

->  gen tabTctsw1=Tctsw if cluster==1
(2,484 missing values generated)

->  gen tabTctsw2=Tctsw if cluster==2
(2,493 missing values generated)

->  gen tabTctsw3=Tctsw if cluster==3
(109 missing values generated)

->  gen tabTctsw4=Tctsw if cluster==4
(2,529 missing values generated)

->  gen tabTctnsw1=Tctnsw if cluster==1
(2,484 missing values generated)

->  gen tabTctnsw2=Tctnsw if cluster==2
(2,493 missing values generated)

->  gen tabTctnsw3=Tctnsw if cluster==3
(109 missing values generated)

->  gen tabTctnsw4=Tctnsw if cluster==4
(2,529 missing values generated)

. for var T* I* U* G* N* C* pop:
> \ gen temp1=X if msa!=9999 \ egen sumX=sum(temp1), by(period) \ gen shX=X/sumX if msa!=9999  \ drop sumX temp1;

-> 

->  gen temp1=Tcttot if msa!=9999
(9 missing values generated)

->  egen sumTcttot=sum(temp1), by(period)

->  gen shTcttot=Tcttot/sumTcttot if msa!=9999
(9 missing values generated)

->  drop sumTcttot temp1

-> 

->  gen temp1=Tctsw if msa!=9999
(9 missing values generated)

->  egen sumTctsw=sum(temp1), by(period)

->  gen shTctsw=Tctsw/sumTctsw if msa!=9999
(9 missing values generated)

->  drop sumTctsw temp1

-> 

->  gen temp1=Tctnsw if msa!=9999
(9 missing values generated)

->  egen sumTctnsw=sum(temp1), by(period)

->  gen shTctnsw=Tctnsw/sumTctnsw if msa!=9999
(9 missing values generated)

->  drop sumTctnsw temp1

-> 

->  gen temp1=Icttot if msa!=9999
(9 missing values generated)

->  egen sumIcttot=sum(temp1), by(period)

->  gen shIcttot=Icttot/sumIcttot if msa!=9999
(9 missing values generated)

->  drop sumIcttot temp1

-> 

->  gen temp1=Ictsw if msa!=9999
(9 missing values generated)

->  egen sumIctsw=sum(temp1), by(period)

->  gen shIctsw=Ictsw/sumIctsw if msa!=9999
(9 missing values generated)

->  drop sumIctsw temp1

-> 

->  gen temp1=Ictnsw if msa!=9999
(9 missing values generated)

->  egen sumIctnsw=sum(temp1), by(period)

->  gen shIctnsw=Ictnsw/sumIctnsw if msa!=9999
(9 missing values generated)

->  drop sumIctnsw temp1

-> 

->  gen temp1=Ucttot if msa!=9999
(9 missing values generated)

->  egen sumUcttot=sum(temp1), by(period)

->  gen shUcttot=Ucttot/sumUcttot if msa!=9999
(9 missing values generated)

->  drop sumUcttot temp1

-> 

->  gen temp1=Uctsw if msa!=9999
(9 missing values generated)

->  egen sumUctsw=sum(temp1), by(period)

->  gen shUctsw=Uctsw/sumUctsw if msa!=9999
(9 missing values generated)

->  drop sumUctsw temp1

-> 

->  gen temp1=Uctnsw if msa!=9999
(9 missing values generated)

->  egen sumUctnsw=sum(temp1), by(period)

->  gen shUctnsw=Uctnsw/sumUctnsw if msa!=9999
(9 missing values generated)

->  drop sumUctnsw temp1

-> 

->  gen temp1=Gcttot if msa!=9999
(9 missing values generated)

->  egen sumGcttot=sum(temp1), by(period)

->  gen shGcttot=Gcttot/sumGcttot if msa!=9999
(9 missing values generated)

->  drop sumGcttot temp1

-> 

->  gen temp1=Gctsw if msa!=9999
(9 missing values generated)

->  egen sumGctsw=sum(temp1), by(period)

->  gen shGctsw=Gctsw/sumGctsw if msa!=9999
(9 missing values generated)

->  drop sumGctsw temp1

-> 

->  gen temp1=Gctnsw if msa!=9999
(9 missing values generated)

->  egen sumGctnsw=sum(temp1), by(period)

->  gen shGctnsw=Gctnsw/sumGctnsw if msa!=9999
(9 missing values generated)

->  drop sumGctnsw temp1

-> 

->  gen temp1=Ncttot if msa!=9999
(9 missing values generated)

->  egen sumNcttot=sum(temp1), by(period)

->  gen shNcttot=Ncttot/sumNcttot if msa!=9999
(9 missing values generated)

->  drop sumNcttot temp1

-> 

->  gen temp1=Nctsw if msa!=9999
(9 missing values generated)

->  egen sumNctsw=sum(temp1), by(period)

->  gen shNctsw=Nctsw/sumNctsw if msa!=9999
(9 missing values generated)

->  drop sumNctsw temp1

-> 

->  gen temp1=Nctnsw if msa!=9999
(9 missing values generated)

->  egen sumNctnsw=sum(temp1), by(period)

->  gen shNctnsw=Nctnsw/sumNctnsw if msa!=9999
(9 missing values generated)

->  drop sumNctnsw temp1

-> 

->  gen temp1=C1cttot if msa!=9999
(9 missing values generated)

->  egen sumC1cttot=sum(temp1), by(period)

->  gen shC1cttot=C1cttot/sumC1cttot if msa!=9999
(9 missing values generated)

->  drop sumC1cttot temp1

-> 

->  gen temp1=C2cttot if msa!=9999
(9 missing values generated)

->  egen sumC2cttot=sum(temp1), by(period)

->  gen shC2cttot=C2cttot/sumC2cttot if msa!=9999
(9 missing values generated)

->  drop sumC2cttot temp1

-> 

->  gen temp1=C3cttot if msa!=9999
(9 missing values generated)

->  egen sumC3cttot=sum(temp1), by(period)

->  gen shC3cttot=C3cttot/sumC3cttot if msa!=9999
(9 missing values generated)

->  drop sumC3cttot temp1

-> 

->  gen temp1=C1ctsw if msa!=9999
(9 missing values generated)

->  egen sumC1ctsw=sum(temp1), by(period)

->  gen shC1ctsw=C1ctsw/sumC1ctsw if msa!=9999
(9 missing values generated)

->  drop sumC1ctsw temp1

-> 

->  gen temp1=C2ctsw if msa!=9999
(9 missing values generated)

->  egen sumC2ctsw=sum(temp1), by(period)

->  gen shC2ctsw=C2ctsw/sumC2ctsw if msa!=9999
(9 missing values generated)

->  drop sumC2ctsw temp1

-> 

->  gen temp1=C3ctsw if msa!=9999
(9 missing values generated)

->  egen sumC3ctsw=sum(temp1), by(period)

->  gen shC3ctsw=C3ctsw/sumC3ctsw if msa!=9999
(9 missing values generated)

->  drop sumC3ctsw temp1

-> 

->  gen temp1=C1ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC1ctnsw=sum(temp1), by(period)

->  gen shC1ctnsw=C1ctnsw/sumC1ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC1ctnsw temp1

-> 

->  gen temp1=C2ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC2ctnsw=sum(temp1), by(period)

->  gen shC2ctnsw=C2ctnsw/sumC2ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC2ctnsw temp1

-> 

->  gen temp1=C3ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC3ctnsw=sum(temp1), by(period)

->  gen shC3ctnsw=C3ctnsw/sumC3ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC3ctnsw temp1

-> 

->  gen temp1=pop if msa!=9999
(9 missing values generated)

->  egen sumpop=sum(temp1), by(period)

->  gen shpop=pop/sumpop if msa!=9999
(9 missing values generated)

->  drop sumpop temp1

. for var T* I* U* G* N* C* pop: gen hhiX=shX^2 if msa!=9999;

->  gen hhiTcttot=shTcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiTctsw=shTctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiTctnsw=shTctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiIcttot=shIcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiIctsw=shIctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiIctnsw=shIctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiUcttot=shUcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiUctsw=shUctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiUctnsw=shUctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiGcttot=shGcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiGctsw=shGctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiGctnsw=shGctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiNcttot=shNcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiNctsw=shNctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiNctnsw=shNctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC1cttot=shC1cttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiC2cttot=shC2cttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiC3cttot=shC3cttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiC1ctsw=shC1ctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC2ctsw=shC2ctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC3ctsw=shC3ctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC1ctnsw=shC1ctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC2ctnsw=shC2ctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC3ctnsw=shC3ctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhipop=shpop^2 if msa!=9999
(9 missing values generated)

. for var T* I* U* G* N* C*: gen egX=(shX-shpop)^2 if msa!=9999;

->  gen egTcttot=(shTcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egTctsw=(shTctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egTctnsw=(shTctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egIcttot=(shIcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egIctsw=(shIctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egIctnsw=(shIctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egUcttot=(shUcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egUctsw=(shUctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egUctnsw=(shUctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egGcttot=(shGcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egGctsw=(shGctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egGctnsw=(shGctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egNcttot=(shNcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egNctsw=(shNctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egNctnsw=(shNctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC1cttot=(shC1cttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC2cttot=(shC2cttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC3cttot=(shC3cttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC1ctsw=(shC1ctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC2ctsw=(shC2ctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC3ctsw=(shC3ctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC1ctnsw=(shC1ctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC2ctnsw=(shC2ctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC3ctnsw=(shC3ctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

. for var hhi* eg*: replace X=. if msa==9999;

->  replace hhiTcttot=. if msa==9999
(0 real changes made)

->  replace hhiTctsw=. if msa==9999
(0 real changes made)

->  replace hhiTctnsw=. if msa==9999
(0 real changes made)

->  replace hhiIcttot=. if msa==9999
(0 real changes made)

->  replace hhiIctsw=. if msa==9999
(0 real changes made)

->  replace hhiIctnsw=. if msa==9999
(0 real changes made)

->  replace hhiUcttot=. if msa==9999
(0 real changes made)

->  replace hhiUctsw=. if msa==9999
(0 real changes made)

->  replace hhiUctnsw=. if msa==9999
(0 real changes made)

->  replace hhiGcttot=. if msa==9999
(0 real changes made)

->  replace hhiGctsw=. if msa==9999
(0 real changes made)

->  replace hhiGctnsw=. if msa==9999
(0 real changes made)

->  replace hhiNcttot=. if msa==9999
(0 real changes made)

->  replace hhiNctsw=. if msa==9999
(0 real changes made)

->  replace hhiNctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC1cttot=. if msa==9999
(0 real changes made)

->  replace hhiC2cttot=. if msa==9999
(0 real changes made)

->  replace hhiC3cttot=. if msa==9999
(0 real changes made)

->  replace hhiC1ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC2ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC3ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC1ctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC2ctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC3ctnsw=. if msa==9999
(0 real changes made)

->  replace hhipop=. if msa==9999
(0 real changes made)

->  replace egTcttot=. if msa==9999
(0 real changes made)

->  replace egTctsw=. if msa==9999
(0 real changes made)

->  replace egTctnsw=. if msa==9999
(0 real changes made)

->  replace egIcttot=. if msa==9999
(0 real changes made)

->  replace egIctsw=. if msa==9999
(0 real changes made)

->  replace egIctnsw=. if msa==9999
(0 real changes made)

->  replace egUcttot=. if msa==9999
(0 real changes made)

->  replace egUctsw=. if msa==9999
(0 real changes made)

->  replace egUctnsw=. if msa==9999
(0 real changes made)

->  replace egGcttot=. if msa==9999
(0 real changes made)

->  replace egGctsw=. if msa==9999
(0 real changes made)

->  replace egGctnsw=. if msa==9999
(0 real changes made)

->  replace egNcttot=. if msa==9999
(0 real changes made)

->  replace egNctsw=. if msa==9999
(0 real changes made)

->  replace egNctnsw=. if msa==9999
(0 real changes made)

->  replace egC1cttot=. if msa==9999
(0 real changes made)

->  replace egC2cttot=. if msa==9999
(0 real changes made)

->  replace egC3cttot=. if msa==9999
(0 real changes made)

->  replace egC1ctsw=. if msa==9999
(0 real changes made)

->  replace egC2ctsw=. if msa==9999
(0 real changes made)

->  replace egC3ctsw=. if msa==9999
(0 real changes made)

->  replace egC1ctnsw=. if msa==9999
(0 real changes made)

->  replace egC2ctnsw=. if msa==9999
(0 real changes made)

->  replace egC3ctnsw=. if msa==9999
(0 real changes made)

. collapse (sum) T* I* U* G* N* C* Z* tab* hhi* eg*, by(period) fast;

. for var tabTcttot*: gen rawX=X \ replace X=X/Tcttot;

->  gen rawtabTcttot1=tabTcttot1

->  replace tabTcttot1=tabTcttot1/Tcttot
(9 real changes made)

->  gen rawtabTcttot2=tabTcttot2

->  replace tabTcttot2=tabTcttot2/Tcttot
(9 real changes made)

->  gen rawtabTcttot3=tabTcttot3

->  replace tabTcttot3=tabTcttot3/Tcttot
(9 real changes made)

->  gen rawtabTcttot4=tabTcttot4

->  replace tabTcttot4=tabTcttot4/Tcttot
(9 real changes made)

. for var tabTctsw*: gen rawX=X \ replace X=X/Tctsw;

->  gen rawtabTctsw1=tabTctsw1

->  replace tabTctsw1=tabTctsw1/Tctsw
(9 real changes made)

->  gen rawtabTctsw2=tabTctsw2

->  replace tabTctsw2=tabTctsw2/Tctsw
(9 real changes made)

->  gen rawtabTctsw3=tabTctsw3

->  replace tabTctsw3=tabTctsw3/Tctsw
(9 real changes made)

->  gen rawtabTctsw4=tabTctsw4

->  replace tabTctsw4=tabTctsw4/Tctsw
(9 real changes made)

. for var tabTctnsw*: gen rawX=X \ replace X=X/Tctnsw;

->  gen rawtabTctnsw1=tabTctnsw1

->  replace tabTctnsw1=tabTctnsw1/Tctnsw
(9 real changes made)

->  gen rawtabTctnsw2=tabTctnsw2

->  replace tabTctnsw2=tabTctnsw2/Tctnsw
(9 real changes made)

->  gen rawtabTctnsw3=tabTctnsw3

->  replace tabTctnsw3=tabTctnsw3/Tctnsw
(9 real changes made)

->  gen rawtabTctnsw4=tabTctnsw4

->  replace tabTctnsw4=tabTctnsw4/Tctnsw
(9 real changes made)

. for var eg*: replace X=X/(1-hhipop);

->  replace egTcttot=egTcttot/(1-hhipop)
(9 real changes made)

->  replace egTctsw=egTctsw/(1-hhipop)
(9 real changes made)

->  replace egTctnsw=egTctnsw/(1-hhipop)
(9 real changes made)

->  replace egIcttot=egIcttot/(1-hhipop)
(9 real changes made)

->  replace egIctsw=egIctsw/(1-hhipop)
(9 real changes made)

->  replace egIctnsw=egIctnsw/(1-hhipop)
(9 real changes made)

->  replace egUcttot=egUcttot/(1-hhipop)
(9 real changes made)

->  replace egUctsw=egUctsw/(1-hhipop)
(9 real changes made)

->  replace egUctnsw=egUctnsw/(1-hhipop)
(9 real changes made)

->  replace egGcttot=egGcttot/(1-hhipop)
(9 real changes made)

->  replace egGctsw=egGctsw/(1-hhipop)
(9 real changes made)

->  replace egGctnsw=egGctnsw/(1-hhipop)
(9 real changes made)

->  replace egNcttot=egNcttot/(1-hhipop)
(9 real changes made)

->  replace egNctsw=egNctsw/(1-hhipop)
(9 real changes made)

->  replace egNctnsw=egNctnsw/(1-hhipop)
(9 real changes made)

->  replace egC1cttot=egC1cttot/(1-hhipop)
(9 real changes made)

->  replace egC2cttot=egC2cttot/(1-hhipop)
(9 real changes made)

->  replace egC3cttot=egC3cttot/(1-hhipop)
(9 real changes made)

->  replace egC1ctsw=egC1ctsw/(1-hhipop)
(9 real changes made)

->  replace egC2ctsw=egC2ctsw/(1-hhipop)
(9 real changes made)

->  replace egC3ctsw=egC3ctsw/(1-hhipop)
(9 real changes made)

->  replace egC1ctnsw=egC1ctnsw/(1-hhipop)
(9 real changes made)

->  replace egC2ctnsw=egC2ctnsw/(1-hhipop)
(9 real changes made)

->  replace egC3ctnsw=egC3ctnsw/(1-hhipop)
(9 real changes made)

. for any T I U G N C1 C2 C3: gen shswX=100*Xctsw/Xcttot;

->  gen shswT=100*Tctsw/Tcttot

->  gen shswI=100*Ictsw/Icttot

->  gen shswU=100*Uctsw/Ucttot

->  gen shswG=100*Gctsw/Gcttot

->  gen shswN=100*Nctsw/Ncttot

->  gen shswC1=100*C1ctsw/C1cttot

->  gen shswC2=100*C2ctsw/C2cttot

->  gen shswC3=100*C3ctsw/C3cttot

. format tab* eg* hhi* %4.3f;

.  format sh* %3.2f;

.  format raw* %8.0f;

.  * Table S1: taken from JEP article;
. * Figure 1;
. for any tot sw nsw:
> list period rawtabTctX*, clean noobs;

->  list period rawtabTcttot*, clean noobs

    period   rawta~t1   rawta~t2   rawta~t3   rawta~t4  
      1975      22302      63773      89964      21858  
      1980      22473      53974      84750      20015  
      1985      29866      59153     102593      22927  
      1990      47997      73966     142263      29347  
      1995     103208      97833     205522      37106  
      2000     144222     106335     235910      40284  
      2005     159763     102014     219982      33929  
      2010     212339     119133     260341      39009  
      2015     169065      91915     202787      30290  

->  list period rawtabTctsw*, clean noobs

    period   raw~tsw1   raw~tsw2   raw~tsw3   raw~tsw4  
      1975       1002       1488       2144        334  
      1980       1728       2350       4017        540  
      1985       3293       3893       6929       1057  
      1990       8536       6768      14086       1784  
      1995      32562      16427      34497       3686  
      2000      61299      24678      56498       5850  
      2005      87700      35253      71516       6732  
      2010     131884      48378      96191       9353  
      2015     111913      42374      83641       8665  

->  list period rawtabTctnsw*, clean noobs

    period   raw~nsw1   raw~nsw2   raw~nsw3   raw~nsw4  
      1975      21300      62285      87820      21524  
      1980      20745      51624      80733      19475  
      1985      26573      55260      95664      21870  
      1990      39461      67198     128177      27563  
      1995      70646      81406     171025      33420  
      2000      82923      81657     179412      34434  
      2005      72063      66761     148466      27197  
      2010      80455      70755     164150      29656  
      2015      57152      49541     119146      21625  

. * Figure 2 & Table S2;
. for any tot sw nsw:
> list period tabTctX*, clean noobs;

->  list period tabTcttot*, clean noobs

    period   tabTc~t1   tabTc~t2   tabTc~t3   tabTc~t4  
      1975      0.113      0.322      0.455      0.110  
      1980      0.124      0.298      0.468      0.110  
      1985      0.139      0.276      0.478      0.107  
      1990      0.163      0.252      0.485      0.100  
      1995      0.233      0.221      0.463      0.084  
      2000      0.274      0.202      0.448      0.076  
      2005      0.310      0.198      0.427      0.066  
      2010      0.337      0.189      0.413      0.062  
      2015      0.342      0.186      0.410      0.061  

->  list period tabTctsw*, clean noobs

    period   tab~tsw1   tab~tsw2   tab~tsw3   tab~tsw4  
      1975      0.202      0.300      0.432      0.067  
      1980      0.200      0.272      0.465      0.063  
      1985      0.217      0.257      0.457      0.070  
      1990      0.274      0.217      0.452      0.057  
      1995      0.374      0.188      0.396      0.042  
      2000      0.413      0.166      0.381      0.039  
      2005      0.436      0.175      0.355      0.033  
      2010      0.461      0.169      0.337      0.033  
      2015      0.454      0.172      0.339      0.035  

->  list period tabTctnsw*, clean noobs

    period   tab~nsw1   tab~nsw2   tab~nsw3   tab~nsw4  
      1975      0.110      0.323      0.455      0.112  
      1980      0.120      0.299      0.468      0.113  
      1985      0.133      0.277      0.480      0.110  
      1990      0.150      0.256      0.488      0.105  
      1995      0.198      0.228      0.480      0.094  
      2000      0.219      0.216      0.474      0.091  
      2005      0.229      0.212      0.472      0.086  
      2010      0.233      0.205      0.476      0.086  
      2015      0.231      0.200      0.481      0.087  

. * Figure 3;
. for any T I U:
> list period egXcttot egXctsw egXctnsw, clean noobs;

->  list period egTcttot egTctsw egTctnsw, clean noobs

    period   egTcttot   egTctsw   egTctnsw  
      1975      0.003     0.009      0.003  
      1980      0.003     0.007      0.003  
      1985      0.003     0.008      0.003  
      1990      0.005     0.017      0.004  
      1995      0.013     0.039      0.009  
      2000      0.020     0.046      0.013  
      2005      0.025     0.050      0.014  
      2010      0.032     0.065      0.014  
      2015      0.033     0.065      0.013  

->  list period egIcttot egIctsw egIctnsw, clean noobs

    period   egIcttot   egIctsw   egIctnsw  
      1975      0.005     0.010      0.005  
      1980      0.005     0.008      0.005  
      1985      0.005     0.009      0.005  
      1990      0.007     0.020      0.006  
      1995      0.018     0.045      0.013  
      2000      0.026     0.052      0.018  
      2005      0.030     0.055      0.019  
      2010      0.039     0.071      0.018  
      2015      0.040     0.071      0.017  

->  list period egUcttot egUctsw egUctnsw, clean noobs

    period   egUcttot   egUctsw   egUctnsw  
      1975      0.032     0.052      0.032  
      1980      0.020     0.034      0.020  
      1985      0.021     0.029      0.020  
      1990      0.018     0.025      0.018  
      1995      0.016     0.018      0.016  
      2000      0.013     0.013      0.013  
      2005      0.011     0.009      0.012  
      2010      0.012     0.012      0.012  
      2015      0.013     0.014      0.013  

. * Figure 4;
. list period Z*, clean noobs;

    period   Z1ctsw   Z1ctnsw   Z2ctsw   Z2ctnsw   Z3ctsw   Z3ctnsw   Z4ctsw   Z4ctnsw   Z5ctsw   Z5ctnsw   Z6ctsw   Z6ctnsw  
      1975      195     42676     2315     11932      139     10714     1143     30977      756     44736      420     51894  
      1980      383     39610     4234     11962      347     12681     1829     28627     1070     35699      772     43998  
      1985      693     40584     7376     14188      830     19630     3164     33237     1930     39639     1179     52089  
      1990     1483     49898    17059     22375     2140     33893     5268     43062     3005     48813     2219     64358  
      1995     2815     57960    59512     45624     5440     58446    10079     61971     5292     56505     4034     75991  
      2000     4163     54560   103756     53571     8349     59974    17269     77210     8227     60436     6561     72675  
      2005     4435     43182   144353     43077    10820     55236    23579     69355     9866     47897     8148     55740  
      2010     6855     46613   198004     35005    19014     75161    35059     71999    13378     50337    13496     65901  
      2015     5389     27333   166154     22928    15827     53702    32395     53646    14087     38808    12741     51047  

. * Table S3;
. for any T C1 C2 C3:
> list period Xcttot Xctsw shswX hhiXcttot hhiXctsw hhiXctnsw egXcttot egXctsw egXctnsw, clean noobs;

->  list period Tcttot Tctsw shswT hhiTcttot hhiTctsw hhiTctnsw egTcttot egTctsw egTctnsw, clean noobs

    period   Tcttot    Tctsw   shswT   hhiTct~t   hhiTctsw   hhiT~nsw   egTcttot   egTctsw   egTctnsw  
      1975   197897     4968    2.51      0.041      0.046      0.041      0.003     0.009      0.003  
      1980   181212     8635    4.77      0.037      0.039      0.037      0.003     0.007      0.003  
      1985   214539    15172    7.07      0.034      0.038      0.034      0.003     0.008      0.003  
      1990   293573    31174   10.62      0.032      0.044      0.031      0.005     0.017      0.004  
      1995   443669    87172   19.65      0.039      0.067      0.035      0.013     0.039      0.009  
      2000   526751   148325   28.16      0.045      0.071      0.038      0.020     0.046      0.013  
      2005   515688   201201   39.02      0.050      0.076      0.038      0.025     0.050      0.014  
      2010   630822   285806   45.31      0.057      0.092      0.038      0.032     0.065      0.014  
      2015   494057   246593   49.91      0.058      0.093      0.036      0.033     0.065      0.013  

->  list period C1cttot C1ctsw shswC1 hhiC1cttot hhiC1ctsw hhiC1ctnsw egC1cttot egC1ctsw egC1ctnsw, clean noobs

    period   C1cttot   C1ctsw   shswC1   hhiC1c~t   hh~1ctsw   h~1ctnsw   egC1ct~t   egC1ctsw   egC1~nsw  
      1975     46367     3458     7.46      0.046      0.049      0.045      0.007      0.012      0.007  
      1980     46652     6063    13.00      0.042      0.043      0.042      0.008      0.010      0.007  
      1985     57965    10540    18.18      0.040      0.041      0.040      0.010      0.011      0.010  
      1990     87764    22327    25.44      0.044      0.052      0.042      0.017      0.025      0.015  
      1995    177186    69591    39.28      0.064      0.077      0.058      0.038      0.049      0.032  
      2000    251806   121025    48.06      0.071      0.082      0.065      0.046      0.057      0.040  
      2005    280364   167932    59.90      0.075      0.087      0.062      0.049      0.060      0.037  
      2010    340067   233063    68.53      0.093      0.108      0.068      0.067      0.081      0.044  
      2015    275123   198549    72.17      0.093      0.108      0.062      0.066      0.080      0.038  

->  list period C2cttot C2ctsw shswC2 hhiC2cttot hhiC2ctsw hhiC2ctnsw egC2cttot egC2ctsw egC2ctnsw, clean noobs

    period   C2cttot   C2ctsw   shswC2   hhiC2c~t   hh~2ctsw   h~2ctnsw   egC2ct~t   egC2ctsw   egC2~nsw  
      1975     53724      334     0.62      0.056      0.062      0.056      0.012      0.014      0.012  
      1980     53021      730     1.38      0.051      0.045      0.051      0.011      0.009      0.011  
      1985     61737     1523     2.47      0.046      0.037      0.046      0.009      0.007      0.010  
      1990     87414     3623     4.14      0.040      0.042      0.040      0.008      0.012      0.009  
      1995    124661     8255     6.62      0.041      0.053      0.040      0.012      0.026      0.011  
      2000    127046    12512     9.85      0.044      0.055      0.043      0.016      0.030      0.015  
      2005    113673    15255    13.42      0.043      0.056      0.042      0.016      0.029      0.015  
      2010    147643    25869    17.52      0.043      0.052      0.042      0.016      0.026      0.015  
      2015    102251    21216    20.75      0.045      0.057      0.043      0.018      0.030      0.016  

->  list period C3cttot C3ctsw shswC3 hhiC3cttot hhiC3ctsw hhiC3ctnsw egC3cttot egC3ctsw egC3ctnsw, clean noobs

    period   C3cttot   C3ctsw   shswC3   hhiC3c~t   hh~3ctsw   h~3ctnsw   egC3ct~t   egC3ctsw   egC3~nsw  
      1975     97806     1176     1.20      0.035      0.040      0.035      0.003      0.006      0.003  
      1980     81539     1842     2.26      0.032      0.032      0.032      0.002      0.004      0.002  
      1985     94837     3109     3.28      0.029      0.035      0.029      0.002      0.004      0.002  
      1990    118395     5224     4.41      0.027      0.031      0.027      0.003      0.006      0.003  
      1995    141822     9326     6.58      0.027      0.033      0.026      0.003      0.006      0.003  
      2000    147899    14788    10.00      0.027      0.034      0.027      0.005      0.010      0.005  
      2005    121651    18014    14.81      0.028      0.037      0.027      0.006      0.012      0.007  
      2010    143112    26874    18.78      0.028      0.042      0.027      0.008      0.018      0.007  
      2015    116683    26828    22.99      0.029      0.044      0.026      0.009      0.022      0.007  

. * Table S4;
. for any I U G N:
> list period Xcttot Xctsw shswX hhiXcttot hhiXctsw hhiXctnsw egXcttot egXctsw egXctnsw, clean noobs;

->  list period Icttot Ictsw shswI hhiIcttot hhiIctsw hhiIctnsw egIcttot egIctsw egIctnsw, clean noobs

    period   Icttot    Ictsw   shswI   hhiIct~t   hhiIctsw   hhiI~nsw   egIcttot   egIctsw   egIctnsw  
      1975   138940     3983    2.87      0.042      0.046      0.043      0.005     0.010      0.005  
      1980   131947     7124    5.40      0.039      0.039      0.039      0.005     0.008      0.005  
      1985   152800    12268    8.03      0.035      0.039      0.035      0.005     0.009      0.005  
      1990   211220    25650   12.14      0.034      0.046      0.033      0.007     0.020      0.006  
      1995   343117    76899   22.41      0.043      0.072      0.038      0.018     0.045      0.013  
      2000   431907   134474   31.13      0.050      0.076      0.043      0.026     0.052      0.018  
      2005   438643   185587   42.31      0.055      0.081      0.042      0.030     0.055      0.019  
      2010   542523   264333   48.72      0.064      0.098      0.042      0.039     0.071      0.018  
      2015   425980   228270   53.59      0.066      0.099      0.040      0.040     0.071      0.017  

->  list period Ucttot Uctsw shswU hhiUcttot hhiUctsw hhiUctnsw egUcttot egUctsw egUctnsw, clean noobs

    period   Ucttot   Uctsw   shswU   hhiUct~t   hhiUctsw   hhiU~nsw   egUcttot   egUctsw   egUctnsw  
      1975     2099     108    5.15      0.054      0.078      0.053      0.032     0.052      0.032  
      1980     3185     220    6.91      0.043      0.057      0.043      0.020     0.034      0.020  
      1985     5723     571    9.98      0.046      0.055      0.045      0.021     0.029      0.020  
      1990    11362    1352   11.90      0.040      0.049      0.040      0.018     0.025      0.018  
      1995    19145    2657   13.88      0.041      0.043      0.041      0.016     0.018      0.016  
      2000    21340    3938   18.45      0.036      0.034      0.037      0.013     0.013      0.013  
      2005    22651    5430   23.97      0.034      0.035      0.034      0.011     0.009      0.012  
      2010    29585    8318   28.12      0.035      0.037      0.035      0.012     0.012      0.012  
      2015    20892    6571   31.45      0.034      0.036      0.034      0.013     0.014      0.013  

->  list period Gcttot Gctsw shswG hhiGcttot hhiGctsw hhiGctnsw egGcttot egGctsw egGctnsw, clean noobs

    period   Gcttot   Gctsw   shswG   hhiGct~t   hhiGctsw   hhiG~nsw   egGcttot   egGctsw   egGctnsw  
      1975     5461     179    3.28      0.060      0.098      0.060      0.039     0.089      0.038  
      1980     4302     236    5.49      0.076      0.072      0.077      0.054     0.055      0.054  
      1985     3108     249    8.01      0.082      0.068      0.085      0.061     0.052      0.063  
      1990     5125     513   10.01      0.110      0.082      0.114      0.091     0.065      0.095  
      1995     4740     661   13.95      0.120      0.078      0.129      0.108     0.067      0.116  
      2000     4793     867   18.09      0.121      0.113      0.124      0.108     0.099      0.111  
      2005     4235     931   21.98      0.120      0.114      0.123      0.106     0.100      0.108  
      2010     4731    1271   26.87      0.123      0.099      0.135      0.109     0.089      0.121  
      2015     3386     996   29.42      0.129      0.120      0.135      0.117     0.109      0.122  

->  list period Ncttot Nctsw shswN hhiNcttot hhiNctsw hhiNctnsw egNcttot egNctsw egNctnsw, clean noobs

    period   Ncttot   Nctsw   shswN   hhiNct~t   hhiNctsw   hhiN~nsw   egNcttot   egNctsw   egNctnsw  
      1975    51426     699    1.36      0.044      0.071      0.044      0.005     0.019      0.005  
      1980    41838    1055    2.52      0.039      0.057      0.039      0.003     0.011      0.003  
      1985    53191    2101    3.95      0.036      0.046      0.036      0.003     0.007      0.003  
      1990    66880    3755    5.61      0.034      0.045      0.033      0.002     0.009      0.002  
      1995    78873    7181    9.10      0.034      0.046      0.034      0.003     0.011      0.002  
      2000    70980    9371   13.20      0.035      0.047      0.034      0.004     0.014      0.003  
      2005    53097    9846   18.54      0.035      0.051      0.033      0.004     0.018      0.003  
      2010    58164   12932   22.23      0.035      0.056      0.032      0.005     0.023      0.003  
      2015    46973   11631   24.76      0.035      0.056      0.031      0.005     0.021      0.003  

. *********************************;
. *** non-MSA Stats Bessen-Hunt ***;
. *********************************;
. * Statistics re San Francisco;
. use patent-spatial-final1, clear;

. tab period, s(software_bh);

            |       Summary of software_bh
     period |        Mean   Std. Dev.       Freq.
------------+------------------------------------
       1975 |   .02510397   .15644131     197,897
       1980 |   .04765137   .21302809     181,212
       1985 |   .07071908    .2563556     214,539
       1990 |   .10618824   .30807892     293,573
       1995 |   .19647981   .39733594     443,669
       2000 |   .28158466    .4497723     526,751
       2005 |   .39016033   .48778654     515,688
       2010 |   .45306917   .49779302     630,822
       2015 |   .49911852   .49999973     494,057
------------+------------------------------------
      Total |   .29416375     .455666   3,498,208

. gen SF=(msa==7362);

. tab period, s(SF);

            |            Summary of SF
     period |        Mean   Std. Dev.       Freq.
------------+------------------------------------
       1975 |   .04576623   .20897824     197,897
       1980 |   .05117211   .22034925     181,212
       1985 |   .05842761    .2345508     214,539
       1990 |   .07215582   .25874618     293,573
       1995 |   .11996105   .32491635     443,669
       2000 |   .14575577   .35286154     526,751
       2005 |   .15923776   .36589801     515,688
       2010 |   .18091474   .38494783     630,822
       2015 |   .18446455   .38786297     494,057
------------+------------------------------------
      Total |   .13419042   .34085684   3,498,208

. tab period if software_bh==1, s(SF);

            |            Summary of SF
     period |        Mean   Std. Dev.       Freq.
------------+------------------------------------
       1975 |   .07306763   .26027368       4,968
       1980 |   .07620151   .26533562       8,635
       1985 |   .09036383   .28671175      15,172
       1990 |   .13376532   .34040546      31,174
       1995 |   .19975451   .39981806      87,172
       2000 |   .21183887   .40861264     148,325
       2005 |   .21958638   .41396746     201,201
       2010 |   .25681756   .43687867     285,806
       2015 |   .25785809   .43745637     246,593
------------+------------------------------------
      Total |   .22988574   .42075938   1,029,046

. tab period if software_bh!=1, s(SF);

            |            Summary of SF
     period |        Mean   Std. Dev.       Freq.
------------+------------------------------------
       1975 |   .04506321   .20744334     192,929
       1980 |   .04991975    .2177798     172,577
       1985 |   .05599723   .22991696     199,367
       1990 |   .06483638   .24623739     262,399
       1995 |   .10044965   .30059902     356,497
       2000 |   .11985434   .32479156     378,426
       2005 |    .1206282   .32569521     314,487
       2010 |     .118038   .32265358     345,016
       2015 |   .11132932   .31454015     247,464
------------+------------------------------------
      Total |   .09430851   .29225751   2,469,162

. * Statistics re Rust Belt;
. *  Buffalo NY, Cincinnati OH, Cleveland OH, Columbus OH, Indianapolis IN, Milwaukee WI, Pittsburgh PA, and St. Louis MO;
. use patent-spatial-final1, clear;

. gen rust=0;

.  for num 1282 1642 1692 1840 3480 5082 6282 7040: replace rust=1 if msa==X;

->  replace rust=1 if msa==1282
(11,275 real changes made)

->  replace rust=1 if msa==1642
(32,607 real changes made)

->  replace rust=1 if msa==1692
(42,999 real changes made)

->  replace rust=1 if msa==1840
(15,427 real changes made)

->  replace rust=1 if msa==3480
(20,122 real changes made)

->  replace rust=1 if msa==5082
(24,398 real changes made)

->  replace rust=1 if msa==6282
(29,633 real changes made)

->  replace rust=1 if msa==7040
(24,934 real changes made)

. tab period, s(rust);

            |           Summary of rust
     period |        Mean   Std. Dev.       Freq.
------------+------------------------------------
       1975 |   .09275027   .29008289     197,897
       1980 |   .08779772   .28300127     181,212
       1985 |   .07838202   .26877242     214,539
       1990 |   .07127699    .2572874     293,573
       1995 |   .06094859   .23923626     443,669
       2000 |   .05289406    .2238222     526,751
       2005 |   .04745893   .21261859     515,688
       2010 |   .04478601   .20683397     630,822
       2015 |    .0440435     .205192     494,057
------------+------------------------------------
      Total |    .0575709   .23293027   3,498,208

. * Table S5a/b;
. use patent-spatial-final1, clear;

. replace fw_selfcite=0 if fw_selfcite==.;
(1,223,223 real changes made)

.  gen forwardext=forward*(1-fw_selfcite);

.  drop fw_selfcite;

.  gen techcl=(cluster==1);

.  gen ct=1;

. collapse (sum) ct (mean) num_claims backward forward forwardext originality generality, by(techcl software_bh period) fast;

. format num_claims backward forward forwardext %3.1f;

.  format originality generality %4.3f;

. sort techcl software_bh period;

. list period ct num_claims backward forward forwardext originality generality if techcl==1 & software_bh==1, clean noobs;

    period       ct   num_cl~s   backward   forward   forwar~t   origin~y   genera~y  
      1975     1002       15.2        6.8      39.6       37.9      0.466      0.677  
      1980     1728       16.0        8.1      49.3       47.9      0.555      0.679  
      1985     3293       17.5        9.9      69.2       66.9      0.588      0.687  
      1990     8536       20.1       11.8      83.9       80.9      0.604      0.697  
      1995    32562       24.2       17.9      80.6       75.5      0.631      0.681  
      2000    61299       26.4       25.9      33.7       30.4      0.649      0.574  
      2005    87700       21.8       29.3      13.6       11.3      0.631      0.418  
      2010   131884       20.9       27.0       6.1        4.5      0.594      0.281  
      2015   111913       20.0       25.1       1.2        0.7      0.569      0.085  

. list period ct num_claims backward forward forwardext originality generality if techcl==0 & software_bh==1, clean noobs;

    period       ct   num_cl~s   backward   forward   forwar~t   origin~y   genera~y  
      1975     3966       15.6        6.4      34.6       33.2      0.493      0.673  
      1980     6907       15.4        8.4      43.1       41.2      0.563      0.675  
      1985    11879       17.3       10.1      54.9       52.4      0.592      0.681  
      1990    22638       18.6       12.3      64.0       60.8      0.605      0.679  
      1995    54610       22.2       19.1      66.0       62.3      0.628      0.665  
      2000    87026       24.6       24.9      31.5       28.1      0.639      0.565  
      2005   113501       20.2       27.8      12.6       10.4      0.620      0.413  
      2010   153922       19.1       29.8       5.8        4.2      0.600      0.282  
      2015   134680       18.5       32.1       1.4        0.7      0.579      0.071  

. list period ct num_claims backward forward forwardext originality generality if techcl==1 & software_bh==0, clean noobs;

    period      ct   num_cl~s   backward   forward   forwar~t   origin~y   genera~y  
      1975   21300       11.1        5.6      19.7       18.8      0.428      0.588  
      1980   20745       12.0        6.9      24.2       23.0      0.492      0.603  
      1985   26573       14.2        8.5      33.5       31.9      0.536      0.614  
      1990   39461       15.8       10.5      42.3       40.0      0.557      0.617  
      1995   70646       19.0       14.7      41.8       38.8      0.580      0.603  
      2000   82923       21.3       23.7      26.7       23.6      0.598      0.526  
      2005   72063       18.7       36.4      12.7       10.0      0.604      0.400  
      2010   80455       17.9       36.8       5.8        3.8      0.594      0.278  
      2015   57152       17.9       35.3       1.2        0.6      0.576      0.054  

. list period ct num_claims backward forward forwardext originality generality if techcl==0 & software_bh==0, clean noobs;

    period       ct   num_cl~s   backward   forward   forwar~t   origin~y   genera~y  
      1975   171629       10.5        5.7      16.5       15.7      0.415      0.578  
      1980   151832       11.5        7.4      20.2       19.0      0.470      0.582  
      1985   172794       13.1        8.9      24.7       23.2      0.511      0.588  
      1990   222938       14.2       10.9      29.4       27.4      0.540      0.588  
      1995   285851       16.8       14.4      28.4       26.0      0.564      0.571  
      2000   295503       19.6       20.6      19.1       16.7      0.583      0.502  
      2005   242424       17.1       26.8      10.8        8.8      0.584      0.378  
      2010   264561       16.7       30.9       5.2        3.8      0.573      0.236  
      2015   190312       16.4       32.6       1.1        0.5      0.553      0.050  

. * Table S6a/b/c;
. use patent-spatial-final1, clear;

. collapse (mean) dENG dCHN dEUR dHIS dHIN dJAP dKOR dRUS dVNM, by(period) fast;

. for var dENG-dVNM: replace X=100*X;

->  replace dENG=100*dENG
(9 real changes made)

->  replace dCHN=100*dCHN
(9 real changes made)

->  replace dEUR=100*dEUR
(9 real changes made)

->  replace dHIS=100*dHIS
(9 real changes made)

->  replace dHIN=100*dHIN
(9 real changes made)

->  replace dJAP=100*dJAP
(9 real changes made)

->  replace dKOR=100*dKOR
(9 real changes made)

->  replace dRUS=100*dRUS
(9 real changes made)

->  replace dVNM=100*dVNM
(9 real changes made)

.  format d* %3.1f;

.  list period d*, clean noobs;

    period   dENG   dCHN   dEUR   dHIS   dHIN   dJAP   dKOR   dRUS   dVNM  
      1975   74.6    2.0   15.5    3.0    1.9    0.5    0.3    2.0    0.1  
      1980   73.2    2.8   15.1    3.0    2.5    0.7    0.5    2.1    0.1  
      1985   72.1    3.3   14.7    3.3    2.8    0.8    0.5    2.2    0.2  
      1990   70.1    4.4   14.1    3.5    3.5    0.9    0.6    2.4    0.3  
      1995   66.3    6.5   13.6    3.6    5.1    1.0    0.7    2.7    0.5  
      2000   62.4    8.7   13.0    3.9    6.3    1.1    0.9    3.1    0.6  
      2005   59.1   10.3   12.3    4.1    7.9    1.2    1.2    3.3    0.6  
      2010   57.1   11.2   11.7    4.6    9.1    1.0    1.3    3.4    0.6  
      2015   55.4   11.6   11.5    5.1   10.0    1.0    1.4    3.4    0.6  

. use patent-spatial-final1, clear;

. collapse (mean) dENG dCHN dEUR dHIS dHIN dJAP dKOR dRUS dVNM, by(nber_cat1) fast;

. for var dENG-dVNM: replace X=100*X;

->  replace dENG=100*dENG
(6 real changes made)

->  replace dCHN=100*dCHN
(6 real changes made)

->  replace dEUR=100*dEUR
(6 real changes made)

->  replace dHIS=100*dHIS
(6 real changes made)

->  replace dHIN=100*dHIN
(6 real changes made)

->  replace dJAP=100*dJAP
(6 real changes made)

->  replace dKOR=100*dKOR
(6 real changes made)

->  replace dRUS=100*dRUS
(6 real changes made)

->  replace dVNM=100*dVNM
(6 real changes made)

.  format d* %3.1f;

.  list nber_cat1 d*, clean noobs;

    nber_c~1   dENG   dCHN   dEUR   dHIS   dHIN   dJAP   dKOR   dRUS   dVNM  
           1   63.6    8.3   13.9    3.7    5.5    1.0    0.9    2.9    0.4  
           2   55.2   11.2   11.7    4.2   11.4    1.1    1.1    3.4    0.6  
           3   61.5    8.6   14.0    4.6    5.7    1.0    1.0    3.1    0.5  
           4   59.2   11.0   12.6    3.8    6.7    1.2    1.4    3.4    0.6  
           5   71.6    3.9   13.8    3.6    3.0    0.8    0.5    2.5    0.3  
           6   73.1    3.2   13.4    4.2    2.5    0.6    0.5    2.2    0.3  

. use patent-spatial-final1, clear;

. collapse (mean) dENG dCHN dEUR dHIS dHIN dJAP dKOR dRUS dVNM, by(software_bh period) fast;

. for var dENG-dVNM: replace X=100*X;

->  replace dENG=100*dENG
(18 real changes made)

->  replace dCHN=100*dCHN
(18 real changes made)

->  replace dEUR=100*dEUR
(18 real changes made)

->  replace dHIS=100*dHIS
(18 real changes made)

->  replace dHIN=100*dHIN
(18 real changes made)

->  replace dJAP=100*dJAP
(18 real changes made)

->  replace dKOR=100*dKOR
(18 real changes made)

->  replace dRUS=100*dRUS
(18 real changes made)

->  replace dVNM=100*dVNM
(18 real changes made)

.  format d* %3.1f;

.  list period d* if software_bh==1, clean noobs;

    period   dENG   dCHN   dEUR   dHIS   dHIN   dJAP   dKOR   dRUS   dVNM  
      1975   76.5    2.1   14.1    2.7    1.7    0.4    0.2    2.2    0.1  
      1980   74.5    2.3   14.6    3.0    2.4    0.7    0.3    2.2    0.1  
      1985   73.5    2.9   13.9    3.0    3.0    0.7    0.4    2.2    0.2  
      1990   69.9    4.9   14.1    3.1    3.9    0.9    0.5    2.4    0.4  
      1995   64.7    7.0   13.4    3.2    6.7    1.1    0.5    2.8    0.6  
      2000   60.5    8.7   12.7    3.8    8.7    1.1    0.7    3.3    0.6  
      2005   56.2   10.6   11.9    4.1   10.8    1.2    1.1    3.5    0.6  
      2010   53.4   12.0   11.3    4.5   12.3    0.9    1.3    3.6    0.5  
      2015   51.4   12.5   11.0    5.0   13.3    0.9    1.6    3.7    0.6  

. list period d* if software_bh==0, clean noobs;

    period   dENG   dCHN   dEUR   dHIS   dHIN   dJAP   dKOR   dRUS   dVNM  
      1975   74.6    2.0   15.5    3.0    1.9    0.5    0.3    2.0    0.1  
      1980   73.1    2.8   15.2    3.0    2.5    0.7    0.5    2.1    0.1  
      1985   72.0    3.4   14.7    3.3    2.8    0.8    0.5    2.2    0.2  
      1990   70.2    4.4   14.2    3.5    3.5    0.9    0.6    2.4    0.3  
      1995   66.7    6.4   13.7    3.7    4.7    1.0    0.7    2.7    0.5  
      2000   63.1    8.7   13.2    4.0    5.4    1.1    1.0    3.0    0.6  
      2005   61.0   10.1   12.5    4.1    6.1    1.2    1.2    3.2    0.6  
      2010   60.1   10.5   12.1    4.7    6.4    1.1    1.2    3.2    0.6  
      2015   59.4   10.7   11.9    5.2    6.7    1.1    1.3    3.2    0.6  

. use patent-spatial-final1, clear;

. collapse (mean) dENG dCHN dEUR dHIS dHIN dJAP dKOR dRUS dVNM, by(software_bh nber_cat1) fast;

. for var dENG-dVNM: replace X=100*X;

->  replace dENG=100*dENG
(12 real changes made)

->  replace dCHN=100*dCHN
(12 real changes made)

->  replace dEUR=100*dEUR
(12 real changes made)

->  replace dHIS=100*dHIS
(12 real changes made)

->  replace dHIN=100*dHIN
(12 real changes made)

->  replace dJAP=100*dJAP
(12 real changes made)

->  replace dKOR=100*dKOR
(12 real changes made)

->  replace dRUS=100*dRUS
(12 real changes made)

->  replace dVNM=100*dVNM
(12 real changes made)

.  format d* %3.1f;

.  list nber_cat1 d* if software_bh==1, clean noobs;

    nber_c~1   dENG   dCHN   dEUR   dHIS   dHIN   dJAP   dKOR   dRUS   dVNM  
           1   61.2    9.4   12.6    3.9    6.4    1.2    1.2    3.5    0.5  
           2   54.3   11.1   11.4    4.3   12.8    1.0    1.1    3.4    0.6  
           3   59.9    8.9   13.7    4.6    6.5    0.8    1.4    3.7    0.5  
           4   56.9   12.1   12.4    4.0    7.8    1.2    1.4    3.7    0.6  
           5   66.2    7.0   12.9    3.8    5.1    0.9    0.8    2.9    0.3  
           6   70.1    4.3   13.2    4.2    3.6    0.8    0.6    2.7    0.5  

. list nber_cat1 d* if software_bh==0, clean noobs;

    nber_c~1   dENG   dCHN   dEUR   dHIS   dHIN   dJAP   dKOR   dRUS   dVNM  
           1   63.7    8.2   14.0    3.6    5.4    0.9    0.9    2.8    0.4  
           2   57.9   11.5   12.4    3.7    7.8    1.5    1.3    3.1    0.8  
           3   61.8    8.5   14.0    4.6    5.5    1.1    1.0    3.0    0.5  
           4   59.9   10.7   12.7    3.8    6.4    1.3    1.3    3.3    0.6  
           5   72.3    3.5   13.9    3.6    2.7    0.8    0.5    2.4    0.2  
           6   73.4    3.1   13.4    4.2    2.4    0.6    0.5    2.1    0.3  

. * Figure S4;
. ;
. use patent-spatial-final1, clear;

. gen dOTH=dJAP+dKOR+dVNM;

. collapse (mean) dCHN dHIN dHIS dRUS dOTH, by(ayear) fast;

. format d* %4.3f;

. list dCHN dHIN dHIS dRUS dOTH, clean noobs;

     dCHN    dHIN    dHIS    dRUS    dOTH  
    0.018   0.016   0.030   0.021   0.009  
    0.020   0.018   0.029   0.019   0.008  
    0.020   0.018   0.031   0.020   0.009  
    0.022   0.019   0.032   0.020   0.010  
    0.023   0.021   0.030   0.020   0.010  
    0.027   0.023   0.031   0.020   0.012  
    0.025   0.023   0.030   0.021   0.011  
    0.028   0.025   0.029   0.023   0.014  
    0.029   0.026   0.031   0.020   0.013  
    0.030   0.026   0.030   0.022   0.014  
    0.032   0.028   0.031   0.022   0.015  
    0.032   0.027   0.033   0.022   0.015  
    0.033   0.027   0.033   0.023   0.015  
    0.034   0.029   0.033   0.023   0.015  
    0.036   0.030   0.033   0.022   0.017  
    0.038   0.031   0.034   0.023   0.017  
    0.041   0.033   0.034   0.024   0.018  
    0.045   0.036   0.034   0.024   0.019  
    0.047   0.037   0.035   0.024   0.019  
    0.049   0.039   0.036   0.025   0.020  
    0.055   0.043   0.035   0.025   0.021  
    0.059   0.045   0.037   0.026   0.021  
    0.064   0.051   0.036   0.027   0.022  
    0.070   0.055   0.037   0.027   0.022  
    0.075   0.057   0.038   0.028   0.023  
    0.080   0.059   0.038   0.030   0.024  
    0.084   0.061   0.039   0.030   0.025  
    0.087   0.062   0.040   0.031   0.026  
    0.089   0.065   0.040   0.031   0.028  
    0.094   0.070   0.039   0.032   0.027  
    0.097   0.075   0.041   0.033   0.030  
    0.101   0.078   0.040   0.033   0.029  
    0.104   0.079   0.040   0.033   0.029  
    0.107   0.083   0.042   0.033   0.029  
    0.107   0.081   0.043   0.034   0.029  
    0.109   0.085   0.044   0.035   0.029  
    0.111   0.087   0.046   0.034   0.027  
    0.112   0.091   0.046   0.034   0.029  
    0.114   0.094   0.047   0.034   0.029  
    0.113   0.095   0.048   0.034   0.029  
    0.113   0.097   0.050   0.035   0.030  
    0.115   0.100   0.051   0.034   0.030  
    0.117   0.101   0.052   0.034   0.030  
    0.120   0.102   0.051   0.034   0.030  
    0.120   0.103   0.052   0.034   0.031  

. * Figure S5;
. use patent-spatial-final1, clear;

. replace dENG=dENG+dEUR;
(1,167,027 real changes made)

.  gen dETH=1-dENG if dENG!=.;

. collapse (sum) dENG dETH, by(cluster period) fast;

. for any dENG dETH: egen temp1=sum(X), by(period) \ replace X=X/temp1 \ drop temp;

->  egen temp1=sum(dENG), by(period)

->  replace dENG=dENG/temp1
(36 real changes made)

->  drop temp

->  egen temp1=sum(dETH), by(period)

->  replace dETH=dETH/temp1
(36 real changes made)

->  drop temp

. table period cluster, c(mean dETH) f(%4.3f);

--------------------------------------
          |          cluster          
   period |     1      2      3      4
----------+---------------------------
     1975 | 0.126  0.404  0.384  0.085
     1980 | 0.148  0.376  0.399  0.077
     1985 | 0.174  0.350  0.407  0.069
     1990 | 0.214  0.314  0.413  0.059
     1995 | 0.318  0.265  0.372  0.044
     2000 | 0.376  0.240  0.347  0.037
     2005 | 0.412  0.233  0.326  0.030
     2010 | 0.443  0.212  0.319  0.026
     2015 | 0.450  0.205  0.320  0.025
--------------------------------------

. table period cluster, c(mean dENG) f(%4.3f);

--------------------------------------
          |          cluster          
   period |     1      2      3      4
----------+---------------------------
     1975 | 0.111  0.313  0.462  0.113
     1980 | 0.121  0.288  0.477  0.115
     1985 | 0.134  0.264  0.489  0.113
     1990 | 0.154  0.240  0.498  0.108
     1995 | 0.211  0.209  0.486  0.093
     2000 | 0.241  0.190  0.481  0.089
     2005 | 0.269  0.184  0.467  0.080
     2010 | 0.289  0.179  0.455  0.078
     2015 | 0.289  0.177  0.455  0.079
--------------------------------------

. use patent-spatial-final1, clear;

. replace dENG=dENG+dEUR;
(1,167,027 real changes made)

.  gen dETH=1-dENG if dENG!=.;

. collapse (sum) dENG dETH, by(cluster software_bh period) fast;

. for any dENG dETH: egen temp1=sum(X), by(period software_bh) \ replace X=X/temp1 \ drop temp;

->  egen temp1=sum(dENG), by(period software_bh)

->  replace dENG=dENG/temp1
(72 real changes made)

->  drop temp

->  egen temp1=sum(dETH), by(period software_bh)

->  replace dETH=dETH/temp1
(72 real changes made)

->  drop temp

. for num 1 0: table period cluster if software_bh==X, c(mean dETH) f(%4.3f);

->  table period cluster if software_bh==1, c(mean dETH) f(%4.3f)

--------------------------------------
          |          cluster          
   period |     1      2      3      4
----------+---------------------------
     1975 | 0.263  0.355  0.321  0.061
     1980 | 0.208  0.338  0.404  0.050
     1985 | 0.245  0.321  0.379  0.054
     1990 | 0.332  0.270  0.360  0.037
     1995 | 0.463  0.222  0.291  0.024
     2000 | 0.519  0.189  0.272  0.020
     2005 | 0.533  0.198  0.253  0.016
     2010 | 0.560  0.177  0.248  0.014
     2015 | 0.555  0.178  0.252  0.015
--------------------------------------

->  table period cluster if software_bh==0, c(mean dETH) f(%4.3f)

--------------------------------------
          |          cluster          
   period |     1      2      3      4
----------+---------------------------
     1975 | 0.123  0.405  0.386  0.086
     1980 | 0.145  0.378  0.399  0.078
     1985 | 0.168  0.353  0.409  0.070
     1990 | 0.199  0.319  0.420  0.062
     1995 | 0.279  0.276  0.395  0.050
     2000 | 0.312  0.262  0.381  0.045
     2005 | 0.319  0.259  0.382  0.040
     2010 | 0.320  0.248  0.394  0.039
     2015 | 0.312  0.241  0.408  0.039
--------------------------------------

. for num 1 0: table period cluster if software_bh==X, c(mean dENG) f(%4.3f);

->  table period cluster if software_bh==1, c(mean dENG) f(%4.3f)

--------------------------------------
          |          cluster          
   period |     1      2      3      4
----------+---------------------------
     1975 | 0.195  0.294  0.443  0.068
     1980 | 0.199  0.264  0.473  0.064
     1985 | 0.213  0.247  0.468  0.072
     1990 | 0.263  0.207  0.469  0.061
     1995 | 0.348  0.179  0.425  0.047
     2000 | 0.375  0.158  0.421  0.047
     2005 | 0.391  0.164  0.403  0.042
     2010 | 0.408  0.165  0.385  0.043
     2015 | 0.393  0.168  0.392  0.047
--------------------------------------

->  table period cluster if software_bh==0, c(mean dENG) f(%4.3f)

--------------------------------------
          |          cluster          
   period |     1      2      3      4
----------+---------------------------
     1975 | 0.109  0.314  0.463  0.114
     1980 | 0.117  0.289  0.477  0.117
     1985 | 0.128  0.266  0.491  0.116
     1990 | 0.141  0.244  0.501  0.113
     1995 | 0.179  0.217  0.500  0.104
     2000 | 0.190  0.201  0.503  0.105
     2005 | 0.197  0.195  0.505  0.103
     2010 | 0.200  0.189  0.507  0.104
     2015 | 0.198  0.184  0.511  0.107
--------------------------------------

. * Software penetration into USPC fields;
. use patent-spatial-final1, clear;

. keep if gyear<=2012 & uspc0!="";
(1,190,300 observations deleted)

.  drop uspc1;

. collapse (mean) software_bh, by(uspc gyear) fast;

. egen temp1=min(gyear), by(uspc);

.  drop if temp1>=1980;
(111 observations deleted)

.  keep if gyear==2012;
(14,747 observations deleted)

. gen sh05=(software_bh>0.05);

. gen sh25=(software_bh>0.25);

. sum;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       gyear |        410        2012           0       2012       2012
       uspc0 |          0
 software_bh |        410    .2028486    .2499861          0          1
       temp1 |        410    1976.044    .2482691       1976       1978
        sh05 |        410          .7    .4588174          0          1
-------------+---------------------------------------------------------
        sh25 |        410    .2463415    .4314062          0          1

. * Decomposition;
. use patent-spatial-final1, clear;

. keep if gyear<=2012 & uspc0!="";
(1,190,300 observations deleted)

.  drop uspc1;

. gen pd=1 if (gyear>=1975 & gyear<=1977);
(2,251,843 missing values generated)

. replace pd=2 if (gyear>=2010 & gyear<=2012);
(345,840 real changes made)

. drop if pd==.;
(1,906,003 observations deleted)

.  gen ct=1;

. collapse (sum) ct (mean) software_bh, by(uspc pd);

. egen temp1=count(pd), by(uspc);

.  keep if temp1==2;
(12 observations deleted)

.  drop temp1;

. reshape wide ct software_bh, i(uspc) j(pd);
(note: j = 1 2)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                      820   ->     410
Number of variables                   4   ->       5
j variable (2 values)                pd   ->   (dropped)
xij variables:
                                     ct   ->   ct1 ct2
                            software_bh   ->   software_bh1 software_bh2
-----------------------------------------------------------------------------

. for num 1/2:
> \ egen totctX=sum(ctX) 
> \ gen shX=ctX/totctX 
> \ egen totswX=sum(ctX*software_bhX)
> \ replace totswX=totswX/totctX;

-> 

->  egen totct1=sum(ct1)

->  gen sh1=ct1/totct1

->  egen totsw1=sum(ct1*software_bh1)

->  replace totsw1=totsw1/totct1
(410 real changes made)

-> 

->  egen totct2=sum(ct2)

->  gen sh2=ct2/totct2

->  egen totsw2=sum(ct2*software_bh2)

->  replace totsw2=totsw2/totct2
(410 real changes made)

. egen Dwithin=sum(sh1*(software_bh2-software_bh1));

. egen Dbtwn=sum((software_bh1-totsw1)*(sh2-sh1));

. egen Dcross=sum((software_bh2-software_bh1)*(sh2-sh1));

. gen Dsw=totsw2-totsw1;

.  gen Pgr1=Dsw/totsw1;

.  for any within btwn cross: gen PX=DX/Dsw;

->  gen Pwithin=Dwithin/Dsw

->  gen Pbtwn=Dbtwn/Dsw

->  gen Pcross=Dcross/Dsw

. gen n=0;

.  collapse (mean) totsw1 totsw2 Pwithin Pbtwn Pcross Pgr1, by(n) fast;

. gen Ptot=Pwithin+Pbtwn+Pcross;

. order n totsw1 totsw2 Pwithin Pbtwn Pcross Pgr1;

. sum;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
           n |          1           0           .          0          0
      totsw1 |          1    .0173733           .   .0173733   .0173733
      totsw2 |          1    .3932259           .   .3932259   .3932259
     Pwithin |          1    .3834587           .   .3834587   .3834587
       Pbtwn |          1    .3693222           .   .3693222   .3693222
-------------+---------------------------------------------------------
      Pcross |          1    .2472191           .   .2472191   .2472191
        Pgr1 |          1    21.63391           .   21.63391   21.63391
        Ptot |          1           1           .          1          1

. * MSA persistence;
. use patent-spatial-final1, clear;

. gen Tctsw=software_bh;

.  gen Tctnsw=1-software_bh;

. drop if msa==9999;
(274,765 observations deleted)

. collapse (sum) T*, by(msa period) fast;

. for any sw nsw: egen temp=sum(TctX), by (period) \ gen SHX=TctX/temp \ drop temp TctX;

->  egen temp=sum(Tctsw), by (period)

->  gen SHsw=Tctsw/temp

->  drop temp Tctsw

->  egen temp=sum(Tctnsw), by (period)

->  gen SHnsw=Tctnsw/temp

->  drop temp Tctnsw

. reshape wide SHsw SHnsw, i(msa) j(period);
(note: j = 1975 1980 1985 1990 1995 2000 2005 2010 2015)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                     2528   ->     281
Number of variables                   4   ->      19
j variable (9 values)            period   ->   (dropped)
xij variables:
                                   SHsw   ->   SHsw1975 SHsw1980 ... SHsw2015
                                  SHnsw   ->   SHnsw1975 SHnsw1980 ... SHnsw2015
-----------------------------------------------------------------------------

. for any sw nsw: pwcorr SHX*;

->  pwcorr SHsw*

             | SHsw1975 SHsw1980 SHsw1985 SHsw1990 SHsw1995 SHsw2000 SHsw2005
-------------+---------------------------------------------------------------
    SHsw1975 |   1.0000 
    SHsw1980 |   0.9864   1.0000 
    SHsw1985 |   0.9692   0.9877   1.0000 
    SHsw1990 |   0.8916   0.9245   0.9637   1.0000 
    SHsw1995 |   0.7667   0.8120   0.8714   0.9631   1.0000 
    SHsw2000 |   0.7096   0.7567   0.8252   0.9317   0.9882   1.0000 
    SHsw2005 |   0.7012   0.7488   0.8166   0.9212   0.9806   0.9965   1.0000 
    SHsw2010 |   0.6689   0.7168   0.7898   0.9066   0.9737   0.9912   0.9931 
    SHsw2015 |   0.6682   0.7151   0.7890   0.9055   0.9740   0.9901   0.9909 

             | SHsw2010 SHsw2015
-------------+------------------
    SHsw2010 |   1.0000 
    SHsw2015 |   0.9987   1.0000 

->  pwcorr SHnsw*

             | SHn~1975 SHn~1980 SHn~1985 SHn~1990 SHn~1995 SHn~2000 SHn~2005
-------------+---------------------------------------------------------------
   SHnsw1975 |   1.0000 
   SHnsw1980 |   0.9962   1.0000 
   SHnsw1985 |   0.9838   0.9927   1.0000 
   SHnsw1990 |   0.9583   0.9734   0.9916   1.0000 
   SHnsw1995 |   0.8761   0.9027   0.9362   0.9671   1.0000 
   SHnsw2000 |   0.8102   0.8418   0.8863   0.9270   0.9892   1.0000 
   SHnsw2005 |   0.8013   0.8353   0.8815   0.9225   0.9848   0.9973   1.0000 
   SHnsw2010 |   0.7907   0.8270   0.8748   0.9156   0.9764   0.9913   0.9970 
   SHnsw2015 |   0.7849   0.8213   0.8699   0.9111   0.9692   0.9849   0.9912 

             | SHn~2010 SHn~2015
-------------+------------------
   SHnsw2010 |   1.0000 
   SHnsw2015 |   0.9965   1.0000 

. * Statistics re universities;
. use patent-spatial-final1, clear;

. gen ct=1;

.  keep if univ==1 & (period==1975 | period==2015);
(3,475,217 observations deleted)

. collapse (sum) ct, by(cluster period);

. reshape wide ct, i(cluster) j(period);
(note: j = 1975 2015)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                        8   ->       4
Number of variables                   3   ->       3
j variable (2 values)            period   ->   (dropped)
xij variables:
                                     ct   ->   ct1975 ct2015
-----------------------------------------------------------------------------

. gen gr=(ct2015/ct1975)^(1/(2015-1975))-1;

. list, clean noobs;

    cluster   ct1975   ct2015         gr  
          1      502     4736   .0577127  
          2      438     4221    .058275  
          3      924    10837   .0634839  
          4      235     1098   .0392939  

. use patent-spatial-final1, clear;

. tab period, s(univ);

            |           Summary of univ
     period |        Mean   Std. Dev.       Freq.
------------+------------------------------------
       1975 |   .01060653   .10244063     197,897
       1980 |    .0175761     .131405     181,212
       1985 |    .0266758   .16113449     214,539
       1990 |   .03870247   .19288524     293,573
       1995 |   .04315154   .20319837     443,669
       2000 |    .0405125   .19715809     526,751
       2005 |   .04392385    .2049259     515,688
       2010 |   .04689913   .21142296     630,822
       2015 |   .04228662    .2012425     494,057
------------+------------------------------------
      Total |    .0388719   .19328965   3,498,208

. tab period if software_bh==1, s(univ);

            |           Summary of univ
     period |        Mean   Std. Dev.       Freq.
------------+------------------------------------
       1975 |   .02173913    .1458452       4,968
       1980 |   .02547771   .15758004       8,635
       1985 |   .03763512   .19031842      15,172
       1990 |   .04336947   .20369068      31,174
       1995 |   .03047997   .17190486      87,172
       2000 |   .02654981   .16076408     148,325
       2005 |   .02698794   .16204851     201,201
       2010 |   .02910366   .16809739     285,806
       2015 |   .02664715   .16105025     246,593
------------+------------------------------------
      Total |   .02834178   .16594745   1,029,046

. tab period if software_bh!=1, s(univ);

            |           Summary of univ
     period |        Mean   Std. Dev.       Freq.
------------+------------------------------------
       1975 |   .01031986   .10106143     192,929
       1980 |   .01718074   .12994482     172,577
       1985 |   .02584179   .15866354     199,367
       1990 |   .03814801   .19155386     262,399
       1995 |   .04625004   .21002642     356,497
       2000 |   .04598521   .20945331     378,426
       2005 |   .05475902   .22750964     314,487
       2010 |   .06164062   .24050202     345,016
       2015 |   .05787104   .23349991     247,464
------------+------------------------------------
      Total |   .04326043   .20344281   2,469,162

. gen ct=1;

.  drop if (ass_id1==. | msa==.);
(492,217 observations deleted)

. collapse (sum) ct (mean) univ, by(ass_id1 msa period) fast;

. gsort msa period -ct ass_id;

.  drop if msa==msa[_n-1] & period==period[_n-1];
(503,387 observations deleted)

.  tab period, s(univ);

            |       Summary of (mean) univ
     period |        Mean   Std. Dev.       Freq.
------------+------------------------------------
       1975 |   .03601918   .18654667         278
       1980 |   .05735258   .23292233         279
       1985 |   .06474048    .2460618         279
       1990 |   .07492758   .26337638         281
       1995 |   .11497149   .31756503         282
       2000 |   .12200896    .3270266         280
       2005 |   .10814274   .30842746         282
       2010 |   .12745879   .33002644         282
       2015 |   .12601973   .32991014         282
------------+------------------------------------
      Total |   .09255192   .28825636       2,525

. use patent-spatial-final1, clear;

. gen ct=software_bh;

.  drop if (ass_id1==. | msa==.);
(492,217 observations deleted)

. collapse (sum) ct (mean) univ, by(ass_id1 msa period) fast;

. gsort msa period -ct ass_id;

.  drop if msa==msa[_n-1] & period==period[_n-1];
(503,387 observations deleted)

.  tab period, s(univ);

            |       Summary of (mean) univ
     period |        Mean   Std. Dev.       Freq.
------------+------------------------------------
       1975 |   .02877698   .16748063         278
       1980 |   .03943144    .1949562         279
       1985 |   .04309217   .20323019         279
       1990 |   .05721142   .23209024         281
       1995 |   .08844366   .28054586         282
       2000 |   .09412621   .29075136         280
       2005 |   .09702071   .29446622         282
       2010 |   .08670109   .27919223         282
       2015 |   .10030346   .29932024         282
------------+------------------------------------
      Total |   .07068993   .25477178       2,525

. use patent-spatial-final1, clear;

. gen ct=1-software_bh;

.  drop if (ass_id1==. | msa==.);
(492,217 observations deleted)

. collapse (sum) ct (mean) univ, by(ass_id1 msa period) fast;

. gsort msa period -ct ass_id;

.  drop if msa==msa[_n-1] & period==period[_n-1];
(503,387 observations deleted)

.  tab period, s(univ);

            |       Summary of (mean) univ
     period |        Mean   Std. Dev.       Freq.
------------+------------------------------------
       1975 |   .03601918   .18654667         278
       1980 |   .06093681   .23963396         279
       1985 |   .06115625   .23958746         279
       1990 |   .08558661   .27993628         281
       1995 |   .11496769   .31756638         282
       2000 |   .11852837   .32280571         280
       2005 |   .13300331   .33767677         282
       2010 |   .15339648   .35594958         282
       2015 |   .13313982   .33779652         282
------------+------------------------------------
      Total |   .09982025   .29806929       2,525

. *** Comparison of reallocation to bottom of distribution;
. use if period==2015 using patent-spatial-final1, clear;

. gen Tcttot=1;

.  collapse (sum) T*, by(msa) fast;

. egen temp1=sum(Tcttot);

.  gen sh=Tcttot/temp1;

.  drop temp1;

. gsort sh Tcttot;

.  gen csh=sh if _n==1;
(281 missing values generated)

.  replace csh=csh[_n-1]+sh if _n>1;
(281 real changes made)

.   list;

     +-------------------------------------+
     |  msa   Tcttot         sh        csh |
     |-------------------------------------|
  1. | 6240        5   .0000101   .0000101 |
  2. | 4200        6   .0000121   .0000223 |
  3. | 3040        8   .0000162   .0000385 |
  4. | 8360        8   .0000162   .0000546 |
  5. | 1900       10   .0000202   .0000749 |
     |-------------------------------------|
  6. | 7000       10   .0000202   .0000951 |
  7. | 4080       10   .0000202   .0001154 |
  8. | 2880       11   .0000223   .0001376 |
  9. | 2340       11   .0000223   .0001599 |
 10. |  450       13   .0000263   .0001862 |
     |-------------------------------------|
 11. |  220       13   .0000263   .0002125 |
 12. | 2180       15   .0000304   .0002429 |
 13. | 3580       15   .0000304   .0002732 |
 14. | 9000       16   .0000324   .0003056 |
 15. | 6025       17   .0000344     .00034 |
     |-------------------------------------|
 16. | 6020       17   .0000344   .0003745 |
 17. | 8320       19   .0000385   .0004129 |
 18. | 9080       19   .0000385   .0004514 |
 19. | 1240       19   .0000385   .0004898 |
 20. | 8080       19   .0000385   .0005283 |
     |-------------------------------------|
 21. | 1950       20   .0000405   .0005688 |
 22. | 2650       20   .0000405   .0006092 |
 23. | 8440       21   .0000425   .0006517 |
 24. |   40       23   .0000466   .0006983 |
 25. | 9360       23   .0000466   .0007449 |
     |-------------------------------------|
 26. | 7200       23   .0000466   .0007914 |
 27. | 1660       24   .0000486     .00084 |
 28. | 3605       24   .0000486   .0008886 |
 29. |  280       24   .0000486   .0009371 |
 30. | 9260       26   .0000526   .0009898 |
     |-------------------------------------|
 31. | 4240       27   .0000546   .0010444 |
 32. | 3180       27   .0000546   .0010991 |
 33. | 4880       28   .0000567   .0011557 |
 34. | 7720       28   .0000567   .0012124 |
 35. |  880       28   .0000567   .0012691 |
     |-------------------------------------|
 36. | 9140       31   .0000627   .0013318 |
 37. | 4100       32   .0000648   .0013966 |
 38. | 2030       33   .0000668   .0014634 |
 39. | 1350       33   .0000668   .0015302 |
 40. | 5280       33   .0000668    .001597 |
     |-------------------------------------|
 41. | 8750       33   .0000668   .0016638 |
 42. | 5800       34   .0000688   .0017326 |
 43. | 3740       35   .0000708   .0018034 |
 44. | 1010       37   .0000749   .0018783 |
 45. | 9340       38   .0000769   .0019552 |
     |-------------------------------------|
 46. | 3610       38   .0000769   .0020322 |
 47. | 3960       39   .0000789   .0021111 |
 48. | 4940       39   .0000789     .00219 |
 49. | 2560       40    .000081    .002271 |
 50. | 7640       40    .000081    .002352 |
     |-------------------------------------|
 51. | 2985       41    .000083   .0024349 |
 52. | 3400       42    .000085     .00252 |
 53. | 5200       42    .000085    .002605 |
 54. | 8940       43    .000087    .002692 |
 55. |  320       43    .000087    .002779 |
     |-------------------------------------|
 56. |  920       44   .0000891   .0028681 |
 57. | 4800       44   .0000891   .0029571 |
 58. | 5990       45   .0000911   .0030482 |
 59. | 3680       45   .0000911   .0031393 |
 60. |  560       45   .0000911   .0032304 |
     |-------------------------------------|
 61. | 6660       45   .0000911   .0033215 |
 62. |  730       49   .0000992   .0034207 |
 63. | 1620       49   .0000992   .0035198 |
 64. | 2750       50   .0001012    .003621 |
 65. | 2655       50   .0001012   .0037222 |
     |-------------------------------------|
 66. | 7610       51   .0001032   .0038255 |
 67. | 1480       51   .0001032   .0039287 |
 68. | 6320       52   .0001053   .0040339 |
 69. | 1300       53   .0001073   .0041412 |
 70. | 6560       53   .0001073   .0042485 |
     |-------------------------------------|
 71. | 3810       54   .0001093   .0043578 |
 72. | 6690       56   .0001133   .0044711 |
 73. | 1800       56   .0001133   .0045845 |
 74. | 8780       57   .0001154   .0046999 |
 75. |  120       58   .0001174   .0048173 |
     |-------------------------------------|
 76. |  400       62   .0001255   .0049427 |
 77. | 2040       63   .0001275   .0050703 |
 78. | 2975       64   .0001295   .0051998 |
 79. | 5320       64   .0001295   .0053293 |
 80. | 4640       66   .0001336   .0054629 |
     |-------------------------------------|
 81. | 7880       67   .0001356   .0055985 |
 82. | 4320       67   .0001356   .0057342 |
 83. | 4680       68   .0001376   .0058718 |
 84. |  780       70   .0001417   .0060135 |
 85. | 8600       71   .0001437   .0061572 |
     |-------------------------------------|
 86. | 5790       75   .0001518    .006309 |
 87. | 2720       75   .0001518   .0064608 |
 88. | 1880       79   .0001599   .0066207 |
 89. | 6015       80   .0001619   .0067826 |
 90. | 5240       81   .0001639   .0069466 |
     |-------------------------------------|
 91. | 3520       83    .000168   .0071146 |
 92. | 2240       85    .000172   .0072866 |
 93. | 5040       86   .0001741   .0074607 |
 94. | 7920       89   .0001801   .0076408 |
 95. |  840       89   .0001801    .007821 |
     |-------------------------------------|
 96. | 4420       90   .0001822   .0080031 |
 97. | 1580       97   .0001963   .0081995 |
 98. | 6450       97   .0001963   .0083958 |
 99. | 8680       97   .0001963   .0085921 |
100. | 3710       97   .0001963   .0087885 |
     |-------------------------------------|
101. | 5170       99   .0002004   .0089888 |
102. | 3560      103   .0002085   .0091973 |
103. | 8800      108   .0002186   .0094159 |
104. | 4890      111   .0002247   .0096406 |
105. | 2320      111   .0002247   .0098653 |
     |-------------------------------------|
106. | 8640      112   .0002267    .010092 |
107. |  380      114   .0002307   .0103227 |
108. | 7080      119   .0002409   .0105636 |
109. | 7680      120   .0002429   .0108064 |
110. | 2290      122   .0002469   .0110534 |
     |-------------------------------------|
111. | 3350      126    .000255   .0113084 |
112. | 3980      126    .000255   .0115634 |
113. | 9200      128   .0002591   .0118225 |
114. | 3080      129   .0002611   .0120836 |
115. | 6980      129   .0002611   .0123447 |
     |-------------------------------------|
116. | 5160      132   .0002672   .0126119 |
117. | 8920      137   .0002773   .0128892 |
118. | 3850      137   .0002773   .0131665 |
119. | 4600      138   .0002793   .0134458 |
120. | 6080      143   .0002894   .0137353 |
     |-------------------------------------|
121. | 4150      144   .0002915   .0140267 |
122. | 3870      145   .0002935   .0143202 |
123. | 2330      149   .0003016   .0146218 |
124. |  600      157   .0003178   .0149396 |
125. | 3620      158   .0003198   .0152594 |
     |-------------------------------------|
126. | 2840      165    .000334   .0155933 |
127. | 5910      165    .000334   .0159273 |
128. | 9320      166    .000336   .0162633 |
129. | 7520      166    .000336   .0165993 |
130. | 6400      170   .0003441   .0169434 |
     |-------------------------------------|
131. | 1740      181   .0003664   .0173097 |
132. | 1260      182   .0003684   .0176781 |
133. | 2020      183   .0003704   .0180485 |
134. | 7760      188   .0003805    .018429 |
135. |  405      189   .0003825   .0188116 |
     |-------------------------------------|
136. | 2200      191   .0003866   .0191982 |
137. |  480      194   .0003927   .0195909 |
138. | 2360      194   .0003927   .0199835 |
139. | 6680      201   .0004068   .0203904 |
140. | 1150      206    .000417   .0208073 |
     |-------------------------------------|
141. | 7560      206    .000417   .0212243 |
142. |  760      206    .000417   .0216412 |
143. | 2335      208    .000421   .0220622 |
144. | 3880      212   .0004291   .0224913 |
145. | 2580      215   .0004352   .0229265 |
     |-------------------------------------|
146. |  500      217   .0004392   .0233657 |
147. | 3660      219   .0004433    .023809 |
148. | 3320      219   .0004433   .0242523 |
149. | 1140      221   .0004473   .0246996 |
150. | 4400      223   .0004514   .0251509 |
     |-------------------------------------|
151. | 6740      224   .0004534   .0256043 |
152. |  860      226   .0004574   .0260618 |
153. | 3500      226   .0004574   .0265192 |
154. | 6800      229   .0004635   .0269827 |
155. | 2710      244   .0004939   .0274766 |
     |-------------------------------------|
156. | 9280      245   .0004959   .0279725 |
157. |  680      246   .0004979   .0284704 |
158. | 2520      247   .0004999   .0289703 |
159. | 1560      249    .000504   .0294743 |
160. | 3060      250    .000506   .0299804 |
     |-------------------------------------|
161. | 8120      254   .0005141   .0304945 |
162. | 7620      254   .0005141   .0310086 |
163. | 7120      260   .0005263   .0315348 |
164. | 8240      261   .0005283   .0320631 |
165. | 8050      264   .0005344   .0325975 |
     |-------------------------------------|
166. | 4040      272   .0005505    .033148 |
167. | 7800      277   .0005607   .0337087 |
168. | 4360      285   .0005769   .0342855 |
169. | 3290      296   .0005991   .0348846 |
170. |  960      301   .0006092   .0354939 |
     |-------------------------------------|
171. | 2400      302   .0006113   .0361051 |
172. | 1020      304   .0006153   .0367205 |
173. | 2640      304   .0006153   .0373358 |
174. | 1000      313   .0006335   .0379693 |
175. | 1540      316   .0006396   .0386089 |
     |-------------------------------------|
176. | 2760      328   .0006639   .0392728 |
177. | 5345      334    .000676   .0399488 |
178. | 7490      339   .0006862    .040635 |
179. | 7510      344   .0006963   .0413313 |
180. | 2440      349   .0007064   .0420377 |
     |-------------------------------------|
181. | 7840      352   .0007125   .0427501 |
182. | 5520      374    .000757   .0435071 |
183. | 1320      385   .0007793   .0442864 |
184. | 9040      392   .0007934   .0450798 |
185. | 2700      401   .0008116   .0458915 |
     |-------------------------------------|
186. | 1760      403   .0008157   .0467072 |
187. | 1960      409   .0008278    .047535 |
188. | 3720      409   .0008278   .0483629 |
189. | 5560      431   .0008724   .0492352 |
190. | 8400      449   .0009088    .050144 |
     |-------------------------------------|
191. | 1440      466   .0009432   .0510872 |
192. | 6880      470   .0009513   .0520385 |
193. | 2900      480   .0009715   .0530101 |
194. | 5720      513   .0010383   .0540484 |
195. | 5920      528   .0010687   .0551171 |
     |-------------------------------------|
196. | 3240      528   .0010687   .0561858 |
197. | 4000      550   .0011132   .0572991 |
198. | 5880      569   .0011517   .0584508 |
199. | 8000      570   .0011537   .0596045 |
200. | 1400      571   .0011557   .0607602 |
     |-------------------------------------|
201. | 5400      587   .0011881   .0619483 |
202. | 3440      609   .0012327    .063181 |
203. | 1360      622    .001259   .0644399 |
204. | 8560      644   .0013035   .0657434 |
205. |  460      647   .0013096    .067053 |
     |-------------------------------------|
206. | 1720      649   .0013136   .0683666 |
207. |  870      651   .0013177   .0696843 |
208. | 2120      698   .0014128   .0710971 |
209. | 4280      707    .001431   .0725281 |
210. | 6960      710   .0014371   .0739652 |
     |-------------------------------------|
211. | 6720      717   .0014512   .0754164 |
212. | 8160      737   .0014917   .0769081 |
213. | 3600      743   .0015039    .078412 |
214. | 3840      746   .0015099    .079922 |
215. | 3920      757   .0015322   .0814542 |
     |-------------------------------------|
216. | 1040      789    .001597   .0830512 |
217. | 1282      799   .0016172   .0846684 |
218. | 4900      833    .001686   .0863544 |
219. | 2000      919   .0018601   .0882145 |
220. | 4920      930   .0018824   .0900969 |
     |-------------------------------------|
221. | 6482      950   .0019229   .0920198 |
222. | 5360      959   .0019411   .0939608 |
223. |  240      972   .0019674   .0959282 |
224. | 6760      982   .0019876   .0979159 |
225. |  200     1005   .0020342     .09995 |
     |-------------------------------------|
226. | 1305     1045   .0021151   .1020652 |
227. | 4520     1064   .0021536   .1042188 |
228. | 2670     1092   .0022103    .106429 |
229. | 6120     1116   .0022588   .1086879 |
230. | 3120     1125   .0022771    .110965 |
     |-------------------------------------|
231. | 7240     1377   .0027871   .1137521 |
232. | 5960     1510   .0030563   .1168084 |
233. | 4720     1517   .0030705   .1198789 |
234. | 4120     1545   .0031272   .1230061 |
235. | 7480     1571   .0031798   .1261859 |
     |-------------------------------------|
236. | 8960     1595   .0032284   .1294142 |
237. | 3000     1614   .0032668   .1326811 |
238. | 3160     1617   .0032729    .135954 |
239. | 6820     1656   .0033518   .1393058 |
240. | 6520     1714   .0034692    .142775 |
     |-------------------------------------|
241. | 1840     1744     .00353    .146305 |
242. | 5480     1755   .0035522   .1498572 |
243. | 3760     1955    .003957   .1538143 |
244. | 9240     1981   .0040097   .1578239 |
245. | 1520     2132   .0043153   .1621392 |
     |-------------------------------------|
246. | 8280     2230   .0045136   .1666529 |
247. | 8520     2236   .0045258   .1711787 |
248. | 6840     2336   .0047282   .1759069 |
249. | 6920     2434   .0049266   .1808334 |
250. | 3480     2503   .0050662   .1858996 |
     |-------------------------------------|
251. | 7160     2506   .0050723   .1909719 |
252. | 6460     2523   .0051067   .1960786 |
253. | 1080     2570   .0052018   .2012805 |
254. | 5082     2613   .0052889   .2065693 |
255. | 6282     2739   .0055439   .2121132 |
     |-------------------------------------|
256. |  720     2814   .0056957   .2178089 |
257. | 7040     2982   .0060357   .2238447 |
258. | 4992     3450    .006983   .2308277 |
259. | 1692     3951   .0079971   .2388247 |
260. | 3282     4046   .0081893    .247014 |
     |-------------------------------------|
261. | 1642     4429   .0089646   .2559786 |
262. |  160     6228   .0126058   .2685844 |
263. | 6200     6464   .0130835   .2816679 |
264. | 6640     6930   .0140267   .2956947 |
265. | 2082     7314    .014804   .3104986 |
     |-------------------------------------|
266. |  520     7412   .0150023   .3255009 |
267. | 6162     8633   .0174737   .3429746 |
268. | 8840     8775   .0177611   .3607357 |
269. | 6442     8924   .0180627   .3787984 |
270. | 5120    10127   .0204976    .399296 |
     |-------------------------------------|
271. |  640    10284   .0208154   .4201114 |
272. | 3362    10619   .0214935   .4416049 |
273. | 1922    10840   .0219408   .4635457 |
274. | 1602    12472   .0252441   .4887898 |
275. | 2162    16391   .0331763   .5219661 |
     |-------------------------------------|
276. | 7320    17495   .0354109    .557377 |
277. | 7602    20201    .040888    .598265 |
278. | 1122    22635   .0458146   .6440796 |
279. | 4472    25468   .0515487   .6956283 |
280. | 5602    28951   .0585985   .7542268 |
     |-------------------------------------|
281. | 9999    30290   .0613087   .8155355 |
282. | 7362    91136   .1844645          1 |
     +-------------------------------------+

. ********************************************;
. *** Extension: Top 4 vs Next 3 Patent Gr ***;
. ********************************************;
. use patent-spatial-final1, clear;

. keep if period==1975 | period==2010;
(2,669,489 observations deleted)

. gen Tct=1;

.  collapse (sum) T* (mean) cluster, by(msa period) fast;

. reshape wide Tct, i(msa) j(period);
(note: j = 1975 2010)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                      564   ->     282
Number of variables                   4   ->       4
j variable (2 values)            period   ->   (dropped)
xij variables:
                                    Tct   ->   Tct1975 Tct2010
-----------------------------------------------------------------------------

. gen grrate1=Tct2010/Tct1975;

. gsort -grrate1;

.  list in 1/20, clean noobs;

     msa   Tct1975   Tct2010   cluster    grrate1  
    1080       100      3379         3      33.79  
    6820       106      2264         3   21.35849  
     640       559     11389         1   20.37388  
    2985         3        54         3         18  
    6640       515      9159         3   17.78447  
    6520        98      1697         3   17.31633  
    7602      1678     25450         1   15.16687  
    7362      9057    114125         1   12.60075  
    1020        50       540         3       10.8  
    6442       989     10679         3   10.79778  
    1305       160      1709         3   10.68125  
    7320      2121     22441         1   10.58039  
    4120       170      1660         3   9.764706  
     520       954      9188         3   9.631027  
    8240        29       278         3   9.586206  
    8520       288      2750         3   9.548611  
    5345        43       372         3   8.651163  
    1720       101       860         3   8.514852  
    3060        29       241         3   8.310345  
    3290        51       422         3   8.274509  

. replace grrate1=. if Tct1975<50;
(83 real changes made, 83 to missing)

. gsort -grrate1;

.  list in 1/20, clean noobs;

     msa   Tct1975   Tct2010   cluster    grrate1  
    1080       100      3379         3      33.79  
    6820       106      2264         3   21.35849  
     640       559     11389         1   20.37388  
    6640       515      9159         3   17.78447  
    6520        98      1697         3   17.31633  
    7602      1678     25450         1   15.16687  
    7362      9057    114125         1   12.60075  
    1020        50       540         3       10.8  
    6442       989     10679         3   10.79778  
    1305       160      1709         3   10.68125  
    7320      2121     22441         1   10.58039  
    4120       170      1660         3   9.764706  
     520       954      9188         3   9.631027  
    8520       288      2750         3   9.548611  
    1720       101       860         3   8.514852  
    3290        51       422         3   8.274509  
    2670       212      1617         3   7.627358  
    7240       223      1654         3    7.41704  
    3920       120       820         3   6.833333  
     200       179      1222         3   6.826816  

. gen chpat=Tct2010-Tct1975;

. gsort -chpat;

.  list in 1/20, clean noobs;

     msa   Tct1975   Tct2010   cluster    grrate1    chpat  
    7362      9057    114125         1   12.60075   105068  
    7602      1678     25450         1   15.16687    23772  
    1122      6868     29601         1   4.309988    22733  
    7320      2121     22441         1   10.58039    20320  
    4472     13617     32563         2   2.391349    18946  
    9999     21858     39009         4   1.784655    17151  
    5602     22772     37576         2   1.650097    14804  
    2162      6045     18648         2   3.084863    12603  
    5120      3439     15450         3   4.492585    12011  
    3362      4030     15733         3    3.90397    11703  
     640       559     11389         1   20.37388    10830  
    1922      2763     13315         3   4.819037    10552  
    6442       989     10679         3   10.79778     9690  
    6640       515      9159         3   17.78447     8644  
     520       954      9188         3   9.631027     8234  
    2082      2019      9333         1   4.622585     7314  
    8840      2967      9587         3    3.23121     6620  
    6200      1781      7717         3   4.332959     5936  
    1602     12304     17707         2   1.439126     5403  
    6162      9035     12639         2   1.398893     3604  

. use patent-spatial-final1, clear;

. drop gyear ayear num_claims backward forward fw_selfcite originality generality dENG-dVNM uspc*;

. for any 2082 640 1602 6162: replace cluster=3 if msa==X;

->  replace cluster=3 if msa==2082
(46,560 real changes made)

->  replace cluster=3 if msa==640
(59,339 real changes made)

->  replace cluster=3 if msa==1602
(121,364 real changes made)

->  replace cluster=3 if msa==6162
(94,314 real changes made)

. * Organize patents and institutions;
. gen Tcttot=1;

.  gen Tctsw=software_bh;

.  gen Tctnsw=1-software_bh;

. for any cttot ctsw ctnsw: gen IX=TX if ind==1 \ gen UX=TX if univ==1 \ gen GX=TX if gov==1 \ gen NX=TX if (ind==0 & gov==0 & univ==0
> );

->  gen Icttot=Tcttot if ind==1
(681,131 missing values generated)

->  gen Ucttot=Tcttot if univ==1
(3,362,226 missing values generated)

->  gen Gcttot=Tcttot if gov==1
(3,458,327 missing values generated)

->  gen Ncttot=Tcttot if (ind==0 & gov==0 & univ==0)
(2,976,786 missing values generated)

->  gen Ictsw=Tctsw if ind==1
(681,131 missing values generated)

->  gen Uctsw=Tctsw if univ==1
(3,362,226 missing values generated)

->  gen Gctsw=Tctsw if gov==1
(3,458,327 missing values generated)

->  gen Nctsw=Tctsw if (ind==0 & gov==0 & univ==0)
(2,976,786 missing values generated)

->  gen Ictnsw=Tctnsw if ind==1
(681,131 missing values generated)

->  gen Uctnsw=Tctnsw if univ==1
(3,362,226 missing values generated)

->  gen Gctnsw=Tctnsw if gov==1
(3,458,327 missing values generated)

->  gen Nctnsw=Tctnsw if (ind==0 & gov==0 & univ==0)
(2,976,786 missing values generated)

. for any cttot ctsw ctnsw: gen C1X=TX if (nber_cat==2 | nber_cat==4) \ gen C2X=TX if (nber_cat==1 | nber_cat==3) \ gen C3X=TX if (nbe
> r_cat==5 | nber_cat==6);

->  gen C1cttot=Tcttot if (nber_cat==2 | nber_cat==4)
(1,934,914 missing values generated)

->  gen C2cttot=Tcttot if (nber_cat==1 | nber_cat==3)
(2,627,038 missing values generated)

->  gen C3cttot=Tcttot if (nber_cat==5 | nber_cat==6)
(2,434,464 missing values generated)

->  gen C1ctsw=Tctsw if (nber_cat==2 | nber_cat==4)
(1,934,914 missing values generated)

->  gen C2ctsw=Tctsw if (nber_cat==1 | nber_cat==3)
(2,627,038 missing values generated)

->  gen C3ctsw=Tctsw if (nber_cat==5 | nber_cat==6)
(2,434,464 missing values generated)

->  gen C1ctnsw=Tctnsw if (nber_cat==2 | nber_cat==4)
(1,934,914 missing values generated)

->  gen C2ctnsw=Tctnsw if (nber_cat==1 | nber_cat==3)
(2,627,038 missing values generated)

->  gen C3ctnsw=Tctnsw if (nber_cat==5 | nber_cat==6)
(2,434,464 missing values generated)

. for num 1/6: gen ZXctsw=Tctsw if nber_cat==X \ gen ZXctnsw=Tctnsw if nber_cat==X;

->  gen Z1ctsw=Tctsw if nber_cat==1
(3,069,381 missing values generated)

->  gen Z1ctnsw=Tctnsw if nber_cat==1
(3,069,381 missing values generated)

->  gen Z2ctsw=Tctsw if nber_cat==2
(2,534,783 missing values generated)

->  gen Z2ctnsw=Tctnsw if nber_cat==2
(2,534,783 missing values generated)

->  gen Z3ctsw=Tctsw if nber_cat==3
(3,055,865 missing values generated)

->  gen Z3ctnsw=Tctnsw if nber_cat==3
(3,055,865 missing values generated)

->  gen Z4ctsw=Tctsw if nber_cat==4
(2,898,339 missing values generated)

->  gen Z4ctnsw=Tctnsw if nber_cat==4
(2,898,339 missing values generated)

->  gen Z5ctsw=Tctsw if nber_cat==5
(3,017,727 missing values generated)

->  gen Z5ctnsw=Tctnsw if nber_cat==5
(3,017,727 missing values generated)

->  gen Z6ctsw=Tctsw if nber_cat==6
(2,914,945 missing values generated)

->  gen Z6ctnsw=Tctnsw if nber_cat==6
(2,914,945 missing values generated)

. * Collapse on MSA-period cells and merge population data;
. * Prepare a zero-valued observation for 7000 in 1980;
. * Fix pop min for early years of 380 (Anchorage AK) and 3320 (Honolulu HI);
. collapse (sum) T* I* U* G* N* C* Z* (mean) cluster, by(msa period) fast;

. sort msa period;

.  merge msa period using period_population_msa;
(note: you are using old merge syntax; see [D] merge for new syntax)

. tab _m;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |          8        0.32        0.32
          2 |          1        0.04        0.35
          3 |      2,529       99.65      100.00
------------+-----------------------------------
      Total |      2,538      100.00

.  table msa _m if _m!=3;

----------------------
          |   _merge  
      msa |    1     2
----------+-----------
      380 |    3      
     3320 |    5      
     7000 |          1
----------------------

.  ren pop pop;

.  for var T* I* U* G* N* C* Z*: replace X=0 if _m==2;

->  replace Tcttot=0 if _m==2
(1 real change made)

->  replace Tctsw=0 if _m==2
(1 real change made)

->  replace Tctnsw=0 if _m==2
(1 real change made)

->  replace Icttot=0 if _m==2
(1 real change made)

->  replace Ictsw=0 if _m==2
(1 real change made)

->  replace Ictnsw=0 if _m==2
(1 real change made)

->  replace Ucttot=0 if _m==2
(1 real change made)

->  replace Uctsw=0 if _m==2
(1 real change made)

->  replace Uctnsw=0 if _m==2
(1 real change made)

->  replace Gcttot=0 if _m==2
(1 real change made)

->  replace Gctsw=0 if _m==2
(1 real change made)

->  replace Gctnsw=0 if _m==2
(1 real change made)

->  replace Ncttot=0 if _m==2
(1 real change made)

->  replace Nctsw=0 if _m==2
(1 real change made)

->  replace Nctnsw=0 if _m==2
(1 real change made)

->  replace C1cttot=0 if _m==2
(1 real change made)

->  replace C2cttot=0 if _m==2
(1 real change made)

->  replace C3cttot=0 if _m==2
(1 real change made)

->  replace C1ctsw=0 if _m==2
(1 real change made)

->  replace C2ctsw=0 if _m==2
(1 real change made)

->  replace C3ctsw=0 if _m==2
(1 real change made)

->  replace C1ctnsw=0 if _m==2
(1 real change made)

->  replace C2ctnsw=0 if _m==2
(1 real change made)

->  replace C3ctnsw=0 if _m==2
(1 real change made)

->  replace Z1ctsw=0 if _m==2
(1 real change made)

->  replace Z1ctnsw=0 if _m==2
(1 real change made)

->  replace Z2ctsw=0 if _m==2
(1 real change made)

->  replace Z2ctnsw=0 if _m==2
(1 real change made)

->  replace Z3ctsw=0 if _m==2
(1 real change made)

->  replace Z3ctnsw=0 if _m==2
(1 real change made)

->  replace Z4ctsw=0 if _m==2
(1 real change made)

->  replace Z4ctnsw=0 if _m==2
(1 real change made)

->  replace Z5ctsw=0 if _m==2
(1 real change made)

->  replace Z5ctnsw=0 if _m==2
(1 real change made)

->  replace Z6ctsw=0 if _m==2
(1 real change made)

->  replace Z6ctnsw=0 if _m==2
(1 real change made)

. egen temp1=min(pop), by(msa);

.  replace pop=temp1 if _m==1;
(8 real changes made)

.  drop _m temp1;

. * Generate components and collapse;
. for var T*: gen tabX1=X if cluster==1 \ gen tabX2=X if cluster==2 \ gen tabX3=X if cluster==3 \ gen tabX4=X if cluster==4;

->  gen tabTcttot1=Tcttot if cluster==1
(2,502 missing values generated)

->  gen tabTcttot2=Tcttot if cluster==2
(2,511 missing values generated)

->  gen tabTcttot3=Tcttot if cluster==3
(73 missing values generated)

->  gen tabTcttot4=Tcttot if cluster==4
(2,529 missing values generated)

->  gen tabTctsw1=Tctsw if cluster==1
(2,502 missing values generated)

->  gen tabTctsw2=Tctsw if cluster==2
(2,511 missing values generated)

->  gen tabTctsw3=Tctsw if cluster==3
(73 missing values generated)

->  gen tabTctsw4=Tctsw if cluster==4
(2,529 missing values generated)

->  gen tabTctnsw1=Tctnsw if cluster==1
(2,502 missing values generated)

->  gen tabTctnsw2=Tctnsw if cluster==2
(2,511 missing values generated)

->  gen tabTctnsw3=Tctnsw if cluster==3
(73 missing values generated)

->  gen tabTctnsw4=Tctnsw if cluster==4
(2,529 missing values generated)

. for var T* I* U* G* N* C* pop:
> \ gen temp1=X if msa!=9999 \ egen sumX=sum(temp1), by(period) \ gen shX=X/sumX if msa!=9999  \ drop sumX temp1;

-> 

->  gen temp1=Tcttot if msa!=9999
(9 missing values generated)

->  egen sumTcttot=sum(temp1), by(period)

->  gen shTcttot=Tcttot/sumTcttot if msa!=9999
(9 missing values generated)

->  drop sumTcttot temp1

-> 

->  gen temp1=Tctsw if msa!=9999
(9 missing values generated)

->  egen sumTctsw=sum(temp1), by(period)

->  gen shTctsw=Tctsw/sumTctsw if msa!=9999
(9 missing values generated)

->  drop sumTctsw temp1

-> 

->  gen temp1=Tctnsw if msa!=9999
(9 missing values generated)

->  egen sumTctnsw=sum(temp1), by(period)

->  gen shTctnsw=Tctnsw/sumTctnsw if msa!=9999
(9 missing values generated)

->  drop sumTctnsw temp1

-> 

->  gen temp1=Icttot if msa!=9999
(9 missing values generated)

->  egen sumIcttot=sum(temp1), by(period)

->  gen shIcttot=Icttot/sumIcttot if msa!=9999
(9 missing values generated)

->  drop sumIcttot temp1

-> 

->  gen temp1=Ictsw if msa!=9999
(9 missing values generated)

->  egen sumIctsw=sum(temp1), by(period)

->  gen shIctsw=Ictsw/sumIctsw if msa!=9999
(9 missing values generated)

->  drop sumIctsw temp1

-> 

->  gen temp1=Ictnsw if msa!=9999
(9 missing values generated)

->  egen sumIctnsw=sum(temp1), by(period)

->  gen shIctnsw=Ictnsw/sumIctnsw if msa!=9999
(9 missing values generated)

->  drop sumIctnsw temp1

-> 

->  gen temp1=Ucttot if msa!=9999
(9 missing values generated)

->  egen sumUcttot=sum(temp1), by(period)

->  gen shUcttot=Ucttot/sumUcttot if msa!=9999
(9 missing values generated)

->  drop sumUcttot temp1

-> 

->  gen temp1=Uctsw if msa!=9999
(9 missing values generated)

->  egen sumUctsw=sum(temp1), by(period)

->  gen shUctsw=Uctsw/sumUctsw if msa!=9999
(9 missing values generated)

->  drop sumUctsw temp1

-> 

->  gen temp1=Uctnsw if msa!=9999
(9 missing values generated)

->  egen sumUctnsw=sum(temp1), by(period)

->  gen shUctnsw=Uctnsw/sumUctnsw if msa!=9999
(9 missing values generated)

->  drop sumUctnsw temp1

-> 

->  gen temp1=Gcttot if msa!=9999
(9 missing values generated)

->  egen sumGcttot=sum(temp1), by(period)

->  gen shGcttot=Gcttot/sumGcttot if msa!=9999
(9 missing values generated)

->  drop sumGcttot temp1

-> 

->  gen temp1=Gctsw if msa!=9999
(9 missing values generated)

->  egen sumGctsw=sum(temp1), by(period)

->  gen shGctsw=Gctsw/sumGctsw if msa!=9999
(9 missing values generated)

->  drop sumGctsw temp1

-> 

->  gen temp1=Gctnsw if msa!=9999
(9 missing values generated)

->  egen sumGctnsw=sum(temp1), by(period)

->  gen shGctnsw=Gctnsw/sumGctnsw if msa!=9999
(9 missing values generated)

->  drop sumGctnsw temp1

-> 

->  gen temp1=Ncttot if msa!=9999
(9 missing values generated)

->  egen sumNcttot=sum(temp1), by(period)

->  gen shNcttot=Ncttot/sumNcttot if msa!=9999
(9 missing values generated)

->  drop sumNcttot temp1

-> 

->  gen temp1=Nctsw if msa!=9999
(9 missing values generated)

->  egen sumNctsw=sum(temp1), by(period)

->  gen shNctsw=Nctsw/sumNctsw if msa!=9999
(9 missing values generated)

->  drop sumNctsw temp1

-> 

->  gen temp1=Nctnsw if msa!=9999
(9 missing values generated)

->  egen sumNctnsw=sum(temp1), by(period)

->  gen shNctnsw=Nctnsw/sumNctnsw if msa!=9999
(9 missing values generated)

->  drop sumNctnsw temp1

-> 

->  gen temp1=C1cttot if msa!=9999
(9 missing values generated)

->  egen sumC1cttot=sum(temp1), by(period)

->  gen shC1cttot=C1cttot/sumC1cttot if msa!=9999
(9 missing values generated)

->  drop sumC1cttot temp1

-> 

->  gen temp1=C2cttot if msa!=9999
(9 missing values generated)

->  egen sumC2cttot=sum(temp1), by(period)

->  gen shC2cttot=C2cttot/sumC2cttot if msa!=9999
(9 missing values generated)

->  drop sumC2cttot temp1

-> 

->  gen temp1=C3cttot if msa!=9999
(9 missing values generated)

->  egen sumC3cttot=sum(temp1), by(period)

->  gen shC3cttot=C3cttot/sumC3cttot if msa!=9999
(9 missing values generated)

->  drop sumC3cttot temp1

-> 

->  gen temp1=C1ctsw if msa!=9999
(9 missing values generated)

->  egen sumC1ctsw=sum(temp1), by(period)

->  gen shC1ctsw=C1ctsw/sumC1ctsw if msa!=9999
(9 missing values generated)

->  drop sumC1ctsw temp1

-> 

->  gen temp1=C2ctsw if msa!=9999
(9 missing values generated)

->  egen sumC2ctsw=sum(temp1), by(period)

->  gen shC2ctsw=C2ctsw/sumC2ctsw if msa!=9999
(9 missing values generated)

->  drop sumC2ctsw temp1

-> 

->  gen temp1=C3ctsw if msa!=9999
(9 missing values generated)

->  egen sumC3ctsw=sum(temp1), by(period)

->  gen shC3ctsw=C3ctsw/sumC3ctsw if msa!=9999
(9 missing values generated)

->  drop sumC3ctsw temp1

-> 

->  gen temp1=C1ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC1ctnsw=sum(temp1), by(period)

->  gen shC1ctnsw=C1ctnsw/sumC1ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC1ctnsw temp1

-> 

->  gen temp1=C2ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC2ctnsw=sum(temp1), by(period)

->  gen shC2ctnsw=C2ctnsw/sumC2ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC2ctnsw temp1

-> 

->  gen temp1=C3ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC3ctnsw=sum(temp1), by(period)

->  gen shC3ctnsw=C3ctnsw/sumC3ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC3ctnsw temp1

-> 

->  gen temp1=pop if msa!=9999
(9 missing values generated)

->  egen sumpop=sum(temp1), by(period)

->  gen shpop=pop/sumpop if msa!=9999
(9 missing values generated)

->  drop sumpop temp1

. collapse (sum) T* I* U* G* N* C* Z* tab*, by(period) fast;

. for var tabTcttot*: replace X=X/Tcttot;

->  replace tabTcttot1=tabTcttot1/Tcttot
(9 real changes made)

->  replace tabTcttot2=tabTcttot2/Tcttot
(9 real changes made)

->  replace tabTcttot3=tabTcttot3/Tcttot
(9 real changes made)

->  replace tabTcttot4=tabTcttot4/Tcttot
(9 real changes made)

. for var tabTctsw*: replace X=X/Tctsw;

->  replace tabTctsw1=tabTctsw1/Tctsw
(9 real changes made)

->  replace tabTctsw2=tabTctsw2/Tctsw
(9 real changes made)

->  replace tabTctsw3=tabTctsw3/Tctsw
(9 real changes made)

->  replace tabTctsw4=tabTctsw4/Tctsw
(9 real changes made)

. for var tabTctnsw*: replace X=X/Tctnsw;

->  replace tabTctnsw1=tabTctnsw1/Tctnsw
(9 real changes made)

->  replace tabTctnsw2=tabTctnsw2/Tctnsw
(9 real changes made)

->  replace tabTctnsw3=tabTctnsw3/Tctnsw
(9 real changes made)

->  replace tabTctnsw4=tabTctnsw4/Tctnsw
(9 real changes made)

. for any T I U G N C1 C2 C3: gen shswX=100*Xctsw/Xcttot;

->  gen shswT=100*Tctsw/Tcttot

->  gen shswI=100*Ictsw/Icttot

->  gen shswU=100*Uctsw/Ucttot

->  gen shswG=100*Gctsw/Gcttot

->  gen shswN=100*Nctsw/Ncttot

->  gen shswC1=100*C1ctsw/C1cttot

->  gen shswC2=100*C2ctsw/C2cttot

->  gen shswC3=100*C3ctsw/C3cttot

. format tab* %4.3f;

.  format sh* %3.2f;

.  * Table S7 - Equivalent to Figure 2 & Table S2;
. for any tot sw nsw:
> list period tabTctX*, clean noobs;

->  list period tabTcttot*, clean noobs

    period   tabTc~t1   tabTc~t2   tabTc~t3   tabTc~t4  
      1975      0.100      0.214      0.575      0.110  
      1980      0.108      0.199      0.582      0.110  
      1985      0.122      0.188      0.583      0.107  
      1990      0.140      0.172      0.588      0.100  
      1995      0.199      0.156      0.561      0.084  
      2000      0.241      0.149      0.534      0.076  
      2005      0.273      0.147      0.515      0.066  
      2010      0.304      0.141      0.494      0.062  
      2015      0.307      0.143      0.489      0.061  

->  list period tabTctsw*, clean noobs

    period   tab~tsw1   tab~tsw2   tab~tsw3   tab~tsw4  
      1975      0.178      0.225      0.530      0.067  
      1980      0.170      0.196      0.571      0.063  
      1985      0.184      0.188      0.559      0.070  
      1990      0.229      0.158      0.555      0.057  
      1995      0.312      0.139      0.507      0.042  
      2000      0.355      0.125      0.481      0.039  
      2005      0.380      0.135      0.451      0.033  
      2010      0.418      0.130      0.419      0.033  
      2015      0.408      0.137      0.420      0.035  

->  list period tabTctnsw*, clean noobs

    period   tab~nsw1   tab~nsw2   tab~nsw3   tab~nsw4  
      1975      0.098      0.214      0.577      0.112  
      1980      0.105      0.199      0.583      0.113  
      1985      0.117      0.188      0.585      0.110  
      1990      0.129      0.174      0.592      0.105  
      1995      0.172      0.160      0.574      0.094  
      2000      0.196      0.158      0.555      0.091  
      2005      0.204      0.154      0.555      0.086  
      2010      0.209      0.150      0.555      0.086  
      2015      0.206      0.150      0.557      0.087  

. *********************************;
. *** Super-Linear Calculation  ***;
. *********************************;
. use patent-spatial-final1, clear;

. gen Tcttot=1;

.  gen Tctsw=software_bh;

.  gen Tctnsw=1-software_bh;

. collapse (sum) T* (mean) cluster, by(msa period) fast;

. sort msa period;

.  merge msa period using period_population_msa;
(note: you are using old merge syntax; see [D] merge for new syntax)

. tab _m;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |          8        0.32        0.32
          2 |          1        0.04        0.35
          3 |      2,529       99.65      100.00
------------+-----------------------------------
      Total |      2,538      100.00

.  table msa _m if _m!=3;

----------------------
          |   _merge  
      msa |    1     2
----------+-----------
      380 |    3      
     3320 |    5      
     7000 |          1
----------------------

.  ren pop pop;

.  for var T*: replace X=0 if _m==2;

->  replace Tcttot=0 if _m==2
(1 real change made)

->  replace Tctsw=0 if _m==2
(1 real change made)

->  replace Tctnsw=0 if _m==2
(1 real change made)

. for var T*: replace X=1 if X<1;

->  replace Tcttot=1 if Tcttot<1
(1 real change made)

->  replace Tctsw=1 if Tctsw<1
(295 real changes made)

->  replace Tctnsw=1 if Tctnsw<1
(1 real change made)

. egen temp1=min(pop), by(msa);

.  replace pop=temp1 if _m==1;
(8 real changes made)

.  drop _m temp1;

. drop if msa==9999;
(9 observations deleted)

. * Table S8: True linear analysis;
. for var T* pop: gen lX=ln(X);

->  gen lTcttot=ln(Tcttot)

->  gen lTctsw=ln(Tctsw)

->  gen lTctnsw=ln(Tctnsw)

->  gen lpop=ln(pop)

. bysort period: regress lTcttot lpop, r;

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1975

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1246.92
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7370
                                                Root MSE          =     .83023

------------------------------------------------------------------------------
             |               Robust
     lTcttot |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.312858    .037179    35.31   0.000     1.239671    1.386045
       _cons |  -13.61985   .5447715   -25.00   0.000    -14.69223   -12.54746
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1980

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1102.88
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7096
                                                Root MSE          =     .89407

------------------------------------------------------------------------------
             |               Robust
     lTcttot |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.327481   .0399728    33.21   0.000     1.248795    1.406168
       _cons |  -13.99945   .5907447   -23.70   0.000    -15.16233   -12.83656
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1985

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1177.26
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7404
                                                Root MSE          =      .8261

------------------------------------------------------------------------------
             |               Robust
     lTcttot |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.312069   .0382402    34.31   0.000     1.236793    1.387345
       _cons |  -13.61842    .563092   -24.19   0.000    -14.72687   -12.50997
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1990

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1170.20
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7446
                                                Root MSE          =     .82201

------------------------------------------------------------------------------
             |               Robust
     lTcttot |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.308641   .0382551    34.21   0.000     1.233336    1.383946
       _cons |  -13.34245   .5617071   -23.75   0.000    -14.44817   -12.23673
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1995

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     978.11
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7205
                                                Root MSE          =     .91511

------------------------------------------------------------------------------
             |               Robust
     lTcttot |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.360515   .0435021    31.27   0.000     1.274881    1.446149
       _cons |  -13.89526   .6408431   -21.68   0.000    -15.15676   -12.63376
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2000

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     913.69
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7083
                                                Root MSE          =     .96949

------------------------------------------------------------------------------
             |               Robust
     lTcttot |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.380937    .045685    30.23   0.000     1.291005    1.470868
       _cons |  -14.19407   .6721026   -21.12   0.000     -15.5171   -12.87103
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2005

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     836.61
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7005
                                                Root MSE          =     1.0325

------------------------------------------------------------------------------
             |               Robust
     lTcttot |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.433517   .0495612    28.92   0.000     1.335955    1.531078
       _cons |  -15.17401    .732107   -20.73   0.000    -16.61516   -13.73285
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2010

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     814.74
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7069
                                                Root MSE          =     1.0251

------------------------------------------------------------------------------
             |               Robust
     lTcttot |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.434533   .0502574    28.54   0.000     1.335602    1.533465
       _cons |  -15.08176    .743686   -20.28   0.000    -16.54571   -13.61781
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2015

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     884.48
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7151
                                                Root MSE          =     .98862

------------------------------------------------------------------------------
             |               Robust
     lTcttot |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.396826   .0469676    29.74   0.000      1.30437    1.489282
       _cons |  -14.49327   .6837032   -21.20   0.000    -15.83914    -13.1474
------------------------------------------------------------------------------

. bysort period: regress lTctsw lpop, r;

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1975

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     553.69
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6436
                                                Root MSE          =      .9009

------------------------------------------------------------------------------
             |               Robust
      lTctsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.143823   .0486102    23.53   0.000     1.048134    1.239513
       _cons |  -15.02322   .6719324   -22.36   0.000    -16.34593   -13.70052
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1980

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     752.35
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6308
                                                Root MSE          =     1.0411

------------------------------------------------------------------------------
             |               Robust
      lTctsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.292841    .047134    27.43   0.000     1.200057    1.385624
       _cons |  -16.79334   .6647396   -25.26   0.000    -18.10188    -15.4848
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1985

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     979.30
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6558
                                                Root MSE          =     1.0697

------------------------------------------------------------------------------
             |               Robust
      lTctsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.388733   .0443774    31.29   0.000     1.301376     1.47609
       _cons |  -17.70766   .6447131   -27.47   0.000    -18.97678   -16.43854
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1990

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     833.13
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6709
                                                Root MSE          =     1.1149

------------------------------------------------------------------------------
             |               Robust
      lTctsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.483981   .0514127    28.86   0.000     1.382775    1.585187
       _cons |  -18.58374    .752677   -24.69   0.000    -20.06539    -17.1021
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1995

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     729.07
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6519
                                                Root MSE          =     1.2656

------------------------------------------------------------------------------
             |               Robust
      lTctsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.603748   .0593951    27.00   0.000     1.486829    1.720667
       _cons |  -19.72181      .8719   -22.62   0.000    -21.43814   -18.00547
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2000

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     691.38
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6439
                                                Root MSE          =       1.32

------------------------------------------------------------------------------
             |               Robust
      lTctsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.622616   .0617102    26.29   0.000     1.501139    1.744093
       _cons |  -19.63668    .906172   -21.67   0.000    -21.42048   -17.85288
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2005

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     722.49
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6548
                                                Root MSE          =     1.3428

------------------------------------------------------------------------------
             |               Robust
      lTctsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.678975   .0624636    26.88   0.000     1.556015    1.801935
       _cons |  -20.37259   .9235061   -22.06   0.000    -22.19051   -18.55466
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2010

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     691.57
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6596
                                                Root MSE          =     1.3314

------------------------------------------------------------------------------
             |               Robust
      lTctsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.670015   .0635044    26.30   0.000     1.545006    1.795023
       _cons |  -19.96488   .9400196   -21.24   0.000    -21.81531   -18.11445
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2015

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     707.05
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6540
                                                Root MSE          =      1.309

------------------------------------------------------------------------------
             |               Robust
      lTctsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.604688   .0603486    26.59   0.000     1.485892    1.723484
       _cons |  -18.78261    .885129   -21.22   0.000    -20.52499   -17.04023
------------------------------------------------------------------------------

. bysort period: regress lTctnsw lpop, r;

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1975

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1258.84
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7386
                                                Root MSE          =     .82429

------------------------------------------------------------------------------
             |               Robust
     lTctnsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.309072   .0368959    35.48   0.000     1.236443    1.381702
       _cons |  -13.58384   .5405992   -25.13   0.000    -14.64801   -12.51967
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1980

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1119.47
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7118
                                                Root MSE          =     .88515

------------------------------------------------------------------------------
             |               Robust
     lTctnsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.321544    .039498    33.46   0.000     1.243793    1.399296
       _cons |  -13.95423   .5837488   -23.90   0.000    -15.10334   -12.80512
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1985

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1193.04
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7427
                                                Root MSE          =     .81591

------------------------------------------------------------------------------
             |               Robust
     lTctnsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.303844   .0377484    34.54   0.000     1.229536    1.378152
       _cons |  -13.56004   .5558277   -24.40   0.000    -14.65419   -12.46589
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1990

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1214.15
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7493
                                                Root MSE          =     .80282

------------------------------------------------------------------------------
             |               Robust
     lTctnsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.293872   .0371326    34.84   0.000     1.220776    1.366968
       _cons |  -13.21274   .5454231   -24.22   0.000    -14.28641   -12.13907
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1995

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1026.90
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7259
                                                Root MSE          =     .88431

------------------------------------------------------------------------------
             |               Robust
     lTctnsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.332514   .0415822    32.05   0.000     1.250659    1.414368
       _cons |  -13.62981    .614292   -22.19   0.000    -14.83905   -12.42057
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2000

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     982.26
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7169
                                                Root MSE          =     .91615

------------------------------------------------------------------------------
             |               Robust
     lTctnsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |    1.33263   .0425203    31.34   0.000     1.248928    1.416331
       _cons |  -13.69605   .6277107   -21.82   0.000     -14.9317    -12.4604
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2005

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     873.05
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7017
                                                Root MSE          =     .97237

------------------------------------------------------------------------------
             |               Robust
     lTctnsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.354004   .0458247    29.55   0.000     1.263798     1.44421
       _cons |  -14.30358   .6789573   -21.07   0.000    -15.64011   -12.96705
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2010

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     856.11
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7093
                                                Root MSE          =     .95417

------------------------------------------------------------------------------
             |               Robust
     lTctnsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.343099   .0459033    29.26   0.000     1.252739     1.43346
       _cons |  -14.09275   .6812842   -20.69   0.000    -15.43386   -12.75164
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2015

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =     950.67
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7236
                                                Root MSE          =     .90742

------------------------------------------------------------------------------
             |               Robust
     lTctnsw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.309237   .0424623    30.83   0.000      1.22565    1.392825
       _cons |  -13.64455   .6196954   -22.02   0.000    -14.86443   -12.42468
------------------------------------------------------------------------------

. * Show 1975-1979 allocations;
. gen temp1=Tcttot if (cluster==1 | cluster==2) & period==1975;
(2,518 missing values generated)

. egen temp2=sum(temp1), by(period);

. gen temp3=Tcttot/temp2 if (cluster==1 | cluster==2) & period==1975;
(2,518 missing values generated)

. tab msa if (cluster==1 | cluster==2) & period==1975, s(temp3);

            |          Summary of temp3
        msa |        Mean   Std. Dev.       Freq.
------------+------------------------------------
        640 |   .00649434           0           1
       1122 |   .07979088           0           1
       1602 |   .14294511           0           1
       2082 |   .02345629           0           1
       2162 |   .07022945           0           1
       4472 |   .15819925           0           1
       5602 |   .26455998           0           1
       6162 |    .1049666           0           1
       7320 |    .0246413           0           1
       7362 |   .10522219           0           1
       7602 |   .01949463           0           1
------------+------------------------------------
      Total |   .09090909   .07714354          11

. egen msash=min(temp3), by(msa);
(2,430 missing values generated)

. drop temp*;

. * Table S8: If no reallocation;
. gen temp1=Tcttot if (cluster==1 | cluster==2);
(2,430 missing values generated)

. egen temp2=sum(temp1), by(period);

. gen Tctrev=Tcttot;

. replace Tctrev=temp2*msash if (cluster==1 | cluster==2);
(89 real changes made)

. drop temp*;

. for var Tctrev: gen lX=ln(X);

->  gen lTctrev=ln(Tctrev)

. bysort period: regress lTctrev lpop, r;

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1975

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1246.92
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7370
                                                Root MSE          =     .83023

------------------------------------------------------------------------------
             |               Robust
     lTctrev |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.312858    .037179    35.31   0.000     1.239671    1.386045
       _cons |  -13.61985   .5447715   -25.00   0.000    -14.69223   -12.54746
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1980

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1122.29
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7099
                                                Root MSE          =      .8914

------------------------------------------------------------------------------
             |               Robust
     lTctrev |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.324603   .0395397    33.50   0.000     1.246769    1.402437
       _cons |   -13.9621   .5852994   -23.85   0.000    -15.11427   -12.80994
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1985

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1223.28
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7401
                                                Root MSE          =     .82248

------------------------------------------------------------------------------
             |               Robust
     lTctrev |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.305353    .037322    34.98   0.000     1.231885    1.378822
       _cons |  -13.52911   .5513221   -24.54   0.000    -14.61439   -12.44383
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1990

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1276.92
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7456
                                                Root MSE          =     .81446

------------------------------------------------------------------------------
             |               Robust
     lTctrev |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.299881   .0363766    35.73   0.000     1.228274    1.371488
       _cons |  -13.22624   .5374392   -24.61   0.000    -14.28419   -12.16829
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 1995

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1166.30
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7250
                                                Root MSE          =     .90155

------------------------------------------------------------------------------
             |               Robust
     lTctrev |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |    1.35553   .0396921    34.15   0.000     1.277396    1.433664
       _cons |  -13.83273   .5913839   -23.39   0.000    -14.99687   -12.66859
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2000

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1136.21
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7138
                                                Root MSE          =     .95447

------------------------------------------------------------------------------
             |               Robust
     lTctrev |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.377861   .0408768    33.71   0.000     1.297395    1.458327
       _cons |  -14.15826   .6091338   -23.24   0.000    -15.35734   -12.95917
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2005

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1040.49
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7067
                                                Root MSE          =     1.0156

------------------------------------------------------------------------------
             |               Robust
     lTctrev |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.431166   .0443682    32.26   0.000     1.343827    1.518505
       _cons |   -15.1486   .6640346   -22.81   0.000    -16.45576   -13.84145
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2010

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1018.13
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7132
                                                Root MSE          =     1.0092

------------------------------------------------------------------------------
             |               Robust
     lTctrev |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.434236    .044949    31.91   0.000     1.345753    1.522718
       _cons |  -15.08452   .6736348   -22.39   0.000    -16.41057   -13.75847
------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
-> period = 2015

Linear regression                               Number of obs     =        281
                                                F(1, 279)         =    1107.87
                                                Prob > F          =     0.0000
                                                R-squared         =     0.7217
                                                Root MSE          =     .97266

------------------------------------------------------------------------------
             |               Robust
     lTctrev |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        lpop |   1.396701   .0419623    33.28   0.000     1.314098    1.479304
       _cons |  -14.49835   .6186765   -23.43   0.000    -15.71622   -13.28048
------------------------------------------------------------------------------

. ********************************************;
. *** Core Graham-Vishnubhakat Results     ***;
. ********************************************;
. use if period!=2015 & software_gv!=. using patent-spatial-final1, clear;

. drop gyear ayear num_claims backward forward fw_selfcite originality generality dENG-dVNM uspc*;

. * Organize patents and institutions;
. gen Tcttot=1;

.  gen Tctsw=software_gv;

.  gen Tctnsw=1-software_gv;

. for any cttot ctsw ctnsw: gen IX=TX if ind==1 \ gen UX=TX if univ==1 \ gen GX=TX if gov==1 \ gen NX=TX if (ind==0 & gov==0 & univ==0
> );

->  gen Icttot=Tcttot if ind==1
(567,081 missing values generated)

->  gen Ucttot=Tcttot if univ==1
(2,557,222 missing values generated)

->  gen Gcttot=Tcttot if gov==1
(2,618,679 missing values generated)

->  gen Ncttot=Tcttot if (ind==0 & gov==0 & univ==0)
(2,205,190 missing values generated)

->  gen Ictsw=Tctsw if ind==1
(567,081 missing values generated)

->  gen Uctsw=Tctsw if univ==1
(2,557,222 missing values generated)

->  gen Gctsw=Tctsw if gov==1
(2,618,679 missing values generated)

->  gen Nctsw=Tctsw if (ind==0 & gov==0 & univ==0)
(2,205,190 missing values generated)

->  gen Ictnsw=Tctnsw if ind==1
(567,081 missing values generated)

->  gen Uctnsw=Tctnsw if univ==1
(2,557,222 missing values generated)

->  gen Gctnsw=Tctnsw if gov==1
(2,618,679 missing values generated)

->  gen Nctnsw=Tctnsw if (ind==0 & gov==0 & univ==0)
(2,205,190 missing values generated)

. for any cttot ctsw ctnsw: gen C1X=TX if (nber_cat==2 | nber_cat==4) \ gen C2X=TX if (nber_cat==1 | nber_cat==3) \ gen C3X=TX if (nbe
> r_cat==5 | nber_cat==6);

->  gen C1cttot=Tcttot if (nber_cat==2 | nber_cat==4)
(1,554,297 missing values generated)

->  gen C2cttot=Tcttot if (nber_cat==1 | nber_cat==3)
(1,971,223 missing values generated)

->  gen C3cttot=Tcttot if (nber_cat==5 | nber_cat==6)
(1,780,072 missing values generated)

->  gen C1ctsw=Tctsw if (nber_cat==2 | nber_cat==4)
(1,554,297 missing values generated)

->  gen C2ctsw=Tctsw if (nber_cat==1 | nber_cat==3)
(1,971,223 missing values generated)

->  gen C3ctsw=Tctsw if (nber_cat==5 | nber_cat==6)
(1,780,072 missing values generated)

->  gen C1ctnsw=Tctnsw if (nber_cat==2 | nber_cat==4)
(1,554,297 missing values generated)

->  gen C2ctnsw=Tctnsw if (nber_cat==1 | nber_cat==3)
(1,971,223 missing values generated)

->  gen C3ctnsw=Tctnsw if (nber_cat==5 | nber_cat==6)
(1,780,072 missing values generated)

. for num 1/6: gen ZXctsw=Tctsw if nber_cat==X \ gen ZXctnsw=Tctnsw if nber_cat==X;

->  gen Z1ctsw=Tctsw if nber_cat==1
(2,284,324 missing values generated)

->  gen Z1ctnsw=Tctnsw if nber_cat==1
(2,284,324 missing values generated)

->  gen Z2ctsw=Tctsw if nber_cat==2
(2,013,095 missing values generated)

->  gen Z2ctnsw=Tctnsw if nber_cat==2
(2,013,095 missing values generated)

->  gen Z3ctsw=Tctsw if nber_cat==3
(2,339,695 missing values generated)

->  gen Z3ctnsw=Tctnsw if nber_cat==3
(2,339,695 missing values generated)

->  gen Z4ctsw=Tctsw if nber_cat==4
(2,193,998 missing values generated)

->  gen Z4ctnsw=Tctnsw if nber_cat==4
(2,193,998 missing values generated)

->  gen Z5ctsw=Tctsw if nber_cat==5
(2,257,277 missing values generated)

->  gen Z5ctnsw=Tctnsw if nber_cat==5
(2,257,277 missing values generated)

->  gen Z6ctsw=Tctsw if nber_cat==6
(2,175,591 missing values generated)

->  gen Z6ctnsw=Tctnsw if nber_cat==6
(2,175,591 missing values generated)

. * Collapse on MSA-period cells and merge population data;
. * Prepare a zero-valued observation for 7000 in 1980;
. * Fix pop min for early years of 380 (Anchorage AK) and 3320 (Honolulu HI);
. collapse (sum) T* I* U* G* N* C* Z* (mean) cluster, by(msa period) fast;

. sort msa period;

.  merge msa period using period_population_msa;
(note: you are using old merge syntax; see [D] merge for new syntax)

. drop if period==2015;
(282 observations deleted)

. tab _m;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |          8        0.35        0.35
          2 |          1        0.04        0.40
          3 |      2,247       99.60      100.00
------------+-----------------------------------
      Total |      2,256      100.00

.  table msa _m if _m!=3;

----------------------
          |   _merge  
      msa |    1     2
----------+-----------
      380 |    3      
     3320 |    5      
     7000 |          1
----------------------

.  ren pop pop;

.  for var T* I* U* G* N* C* Z*: replace X=0 if _m==2;

->  replace Tcttot=0 if _m==2
(1 real change made)

->  replace Tctsw=0 if _m==2
(1 real change made)

->  replace Tctnsw=0 if _m==2
(1 real change made)

->  replace Icttot=0 if _m==2
(1 real change made)

->  replace Ictsw=0 if _m==2
(1 real change made)

->  replace Ictnsw=0 if _m==2
(1 real change made)

->  replace Ucttot=0 if _m==2
(1 real change made)

->  replace Uctsw=0 if _m==2
(1 real change made)

->  replace Uctnsw=0 if _m==2
(1 real change made)

->  replace Gcttot=0 if _m==2
(1 real change made)

->  replace Gctsw=0 if _m==2
(1 real change made)

->  replace Gctnsw=0 if _m==2
(1 real change made)

->  replace Ncttot=0 if _m==2
(1 real change made)

->  replace Nctsw=0 if _m==2
(1 real change made)

->  replace Nctnsw=0 if _m==2
(1 real change made)

->  replace C1cttot=0 if _m==2
(1 real change made)

->  replace C2cttot=0 if _m==2
(1 real change made)

->  replace C3cttot=0 if _m==2
(1 real change made)

->  replace C1ctsw=0 if _m==2
(1 real change made)

->  replace C2ctsw=0 if _m==2
(1 real change made)

->  replace C3ctsw=0 if _m==2
(1 real change made)

->  replace C1ctnsw=0 if _m==2
(1 real change made)

->  replace C2ctnsw=0 if _m==2
(1 real change made)

->  replace C3ctnsw=0 if _m==2
(1 real change made)

->  replace Z1ctsw=0 if _m==2
(1 real change made)

->  replace Z1ctnsw=0 if _m==2
(1 real change made)

->  replace Z2ctsw=0 if _m==2
(1 real change made)

->  replace Z2ctnsw=0 if _m==2
(1 real change made)

->  replace Z3ctsw=0 if _m==2
(1 real change made)

->  replace Z3ctnsw=0 if _m==2
(1 real change made)

->  replace Z4ctsw=0 if _m==2
(1 real change made)

->  replace Z4ctnsw=0 if _m==2
(1 real change made)

->  replace Z5ctsw=0 if _m==2
(1 real change made)

->  replace Z5ctnsw=0 if _m==2
(1 real change made)

->  replace Z6ctsw=0 if _m==2
(1 real change made)

->  replace Z6ctnsw=0 if _m==2
(1 real change made)

. egen temp1=min(pop), by(msa);

.  replace pop=temp1 if _m==1;
(8 real changes made)

.  drop _m temp1;

. * Generate HHI and EG components and collapse;
. for var T*: gen tabX1=X if cluster==1 \ gen tabX2=X if cluster==2 \ gen tabX3=X if cluster==3 \ gen tabX4=X if cluster==4;

->  gen tabTcttot1=Tcttot if cluster==1
(2,208 missing values generated)

->  gen tabTcttot2=Tcttot if cluster==2
(2,216 missing values generated)

->  gen tabTcttot3=Tcttot if cluster==3
(97 missing values generated)

->  gen tabTcttot4=Tcttot if cluster==4
(2,248 missing values generated)

->  gen tabTctsw1=Tctsw if cluster==1
(2,208 missing values generated)

->  gen tabTctsw2=Tctsw if cluster==2
(2,216 missing values generated)

->  gen tabTctsw3=Tctsw if cluster==3
(97 missing values generated)

->  gen tabTctsw4=Tctsw if cluster==4
(2,248 missing values generated)

->  gen tabTctnsw1=Tctnsw if cluster==1
(2,208 missing values generated)

->  gen tabTctnsw2=Tctnsw if cluster==2
(2,216 missing values generated)

->  gen tabTctnsw3=Tctnsw if cluster==3
(97 missing values generated)

->  gen tabTctnsw4=Tctnsw if cluster==4
(2,248 missing values generated)

. for var T* I* U* G* N* C* pop:
> \ gen temp1=X if msa!=9999 \ egen sumX=sum(temp1), by(period) \ gen shX=X/sumX if msa!=9999  \ drop sumX temp1;

-> 

->  gen temp1=Tcttot if msa!=9999
(8 missing values generated)

->  egen sumTcttot=sum(temp1), by(period)

->  gen shTcttot=Tcttot/sumTcttot if msa!=9999
(8 missing values generated)

->  drop sumTcttot temp1

-> 

->  gen temp1=Tctsw if msa!=9999
(8 missing values generated)

->  egen sumTctsw=sum(temp1), by(period)

->  gen shTctsw=Tctsw/sumTctsw if msa!=9999
(8 missing values generated)

->  drop sumTctsw temp1

-> 

->  gen temp1=Tctnsw if msa!=9999
(8 missing values generated)

->  egen sumTctnsw=sum(temp1), by(period)

->  gen shTctnsw=Tctnsw/sumTctnsw if msa!=9999
(8 missing values generated)

->  drop sumTctnsw temp1

-> 

->  gen temp1=Icttot if msa!=9999
(8 missing values generated)

->  egen sumIcttot=sum(temp1), by(period)

->  gen shIcttot=Icttot/sumIcttot if msa!=9999
(8 missing values generated)

->  drop sumIcttot temp1

-> 

->  gen temp1=Ictsw if msa!=9999
(8 missing values generated)

->  egen sumIctsw=sum(temp1), by(period)

->  gen shIctsw=Ictsw/sumIctsw if msa!=9999
(8 missing values generated)

->  drop sumIctsw temp1

-> 

->  gen temp1=Ictnsw if msa!=9999
(8 missing values generated)

->  egen sumIctnsw=sum(temp1), by(period)

->  gen shIctnsw=Ictnsw/sumIctnsw if msa!=9999
(8 missing values generated)

->  drop sumIctnsw temp1

-> 

->  gen temp1=Ucttot if msa!=9999
(8 missing values generated)

->  egen sumUcttot=sum(temp1), by(period)

->  gen shUcttot=Ucttot/sumUcttot if msa!=9999
(8 missing values generated)

->  drop sumUcttot temp1

-> 

->  gen temp1=Uctsw if msa!=9999
(8 missing values generated)

->  egen sumUctsw=sum(temp1), by(period)

->  gen shUctsw=Uctsw/sumUctsw if msa!=9999
(8 missing values generated)

->  drop sumUctsw temp1

-> 

->  gen temp1=Uctnsw if msa!=9999
(8 missing values generated)

->  egen sumUctnsw=sum(temp1), by(period)

->  gen shUctnsw=Uctnsw/sumUctnsw if msa!=9999
(8 missing values generated)

->  drop sumUctnsw temp1

-> 

->  gen temp1=Gcttot if msa!=9999
(8 missing values generated)

->  egen sumGcttot=sum(temp1), by(period)

->  gen shGcttot=Gcttot/sumGcttot if msa!=9999
(8 missing values generated)

->  drop sumGcttot temp1

-> 

->  gen temp1=Gctsw if msa!=9999
(8 missing values generated)

->  egen sumGctsw=sum(temp1), by(period)

->  gen shGctsw=Gctsw/sumGctsw if msa!=9999
(8 missing values generated)

->  drop sumGctsw temp1

-> 

->  gen temp1=Gctnsw if msa!=9999
(8 missing values generated)

->  egen sumGctnsw=sum(temp1), by(period)

->  gen shGctnsw=Gctnsw/sumGctnsw if msa!=9999
(8 missing values generated)

->  drop sumGctnsw temp1

-> 

->  gen temp1=Ncttot if msa!=9999
(8 missing values generated)

->  egen sumNcttot=sum(temp1), by(period)

->  gen shNcttot=Ncttot/sumNcttot if msa!=9999
(8 missing values generated)

->  drop sumNcttot temp1

-> 

->  gen temp1=Nctsw if msa!=9999
(8 missing values generated)

->  egen sumNctsw=sum(temp1), by(period)

->  gen shNctsw=Nctsw/sumNctsw if msa!=9999
(8 missing values generated)

->  drop sumNctsw temp1

-> 

->  gen temp1=Nctnsw if msa!=9999
(8 missing values generated)

->  egen sumNctnsw=sum(temp1), by(period)

->  gen shNctnsw=Nctnsw/sumNctnsw if msa!=9999
(8 missing values generated)

->  drop sumNctnsw temp1

-> 

->  gen temp1=C1cttot if msa!=9999
(8 missing values generated)

->  egen sumC1cttot=sum(temp1), by(period)

->  gen shC1cttot=C1cttot/sumC1cttot if msa!=9999
(8 missing values generated)

->  drop sumC1cttot temp1

-> 

->  gen temp1=C2cttot if msa!=9999
(8 missing values generated)

->  egen sumC2cttot=sum(temp1), by(period)

->  gen shC2cttot=C2cttot/sumC2cttot if msa!=9999
(8 missing values generated)

->  drop sumC2cttot temp1

-> 

->  gen temp1=C3cttot if msa!=9999
(8 missing values generated)

->  egen sumC3cttot=sum(temp1), by(period)

->  gen shC3cttot=C3cttot/sumC3cttot if msa!=9999
(8 missing values generated)

->  drop sumC3cttot temp1

-> 

->  gen temp1=C1ctsw if msa!=9999
(8 missing values generated)

->  egen sumC1ctsw=sum(temp1), by(period)

->  gen shC1ctsw=C1ctsw/sumC1ctsw if msa!=9999
(8 missing values generated)

->  drop sumC1ctsw temp1

-> 

->  gen temp1=C2ctsw if msa!=9999
(8 missing values generated)

->  egen sumC2ctsw=sum(temp1), by(period)

->  gen shC2ctsw=C2ctsw/sumC2ctsw if msa!=9999
(8 missing values generated)

->  drop sumC2ctsw temp1

-> 

->  gen temp1=C3ctsw if msa!=9999
(8 missing values generated)

->  egen sumC3ctsw=sum(temp1), by(period)

->  gen shC3ctsw=C3ctsw/sumC3ctsw if msa!=9999
(8 missing values generated)

->  drop sumC3ctsw temp1

-> 

->  gen temp1=C1ctnsw if msa!=9999
(8 missing values generated)

->  egen sumC1ctnsw=sum(temp1), by(period)

->  gen shC1ctnsw=C1ctnsw/sumC1ctnsw if msa!=9999
(8 missing values generated)

->  drop sumC1ctnsw temp1

-> 

->  gen temp1=C2ctnsw if msa!=9999
(8 missing values generated)

->  egen sumC2ctnsw=sum(temp1), by(period)

->  gen shC2ctnsw=C2ctnsw/sumC2ctnsw if msa!=9999
(8 missing values generated)

->  drop sumC2ctnsw temp1

-> 

->  gen temp1=C3ctnsw if msa!=9999
(8 missing values generated)

->  egen sumC3ctnsw=sum(temp1), by(period)

->  gen shC3ctnsw=C3ctnsw/sumC3ctnsw if msa!=9999
(8 missing values generated)

->  drop sumC3ctnsw temp1

-> 

->  gen temp1=pop if msa!=9999
(8 missing values generated)

->  egen sumpop=sum(temp1), by(period)

->  gen shpop=pop/sumpop if msa!=9999
(8 missing values generated)

->  drop sumpop temp1

. for var T* I* U* G* N* C* pop: gen hhiX=shX^2 if msa!=9999;

->  gen hhiTcttot=shTcttot^2 if msa!=9999
(8 missing values generated)

->  gen hhiTctsw=shTctsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiTctnsw=shTctnsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiIcttot=shIcttot^2 if msa!=9999
(8 missing values generated)

->  gen hhiIctsw=shIctsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiIctnsw=shIctnsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiUcttot=shUcttot^2 if msa!=9999
(8 missing values generated)

->  gen hhiUctsw=shUctsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiUctnsw=shUctnsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiGcttot=shGcttot^2 if msa!=9999
(8 missing values generated)

->  gen hhiGctsw=shGctsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiGctnsw=shGctnsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiNcttot=shNcttot^2 if msa!=9999
(8 missing values generated)

->  gen hhiNctsw=shNctsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiNctnsw=shNctnsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiC1cttot=shC1cttot^2 if msa!=9999
(8 missing values generated)

->  gen hhiC2cttot=shC2cttot^2 if msa!=9999
(8 missing values generated)

->  gen hhiC3cttot=shC3cttot^2 if msa!=9999
(8 missing values generated)

->  gen hhiC1ctsw=shC1ctsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiC2ctsw=shC2ctsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiC3ctsw=shC3ctsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiC1ctnsw=shC1ctnsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiC2ctnsw=shC2ctnsw^2 if msa!=9999
(8 missing values generated)

->  gen hhiC3ctnsw=shC3ctnsw^2 if msa!=9999
(8 missing values generated)

->  gen hhipop=shpop^2 if msa!=9999
(8 missing values generated)

. for var T* I* U* G* N* C*: gen egX=(shX-shpop)^2 if msa!=9999;

->  gen egTcttot=(shTcttot-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egTctsw=(shTctsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egTctnsw=(shTctnsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egIcttot=(shIcttot-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egIctsw=(shIctsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egIctnsw=(shIctnsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egUcttot=(shUcttot-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egUctsw=(shUctsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egUctnsw=(shUctnsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egGcttot=(shGcttot-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egGctsw=(shGctsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egGctnsw=(shGctnsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egNcttot=(shNcttot-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egNctsw=(shNctsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egNctnsw=(shNctnsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egC1cttot=(shC1cttot-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egC2cttot=(shC2cttot-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egC3cttot=(shC3cttot-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egC1ctsw=(shC1ctsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egC2ctsw=(shC2ctsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egC3ctsw=(shC3ctsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egC1ctnsw=(shC1ctnsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egC2ctnsw=(shC2ctnsw-shpop)^2 if msa!=9999
(8 missing values generated)

->  gen egC3ctnsw=(shC3ctnsw-shpop)^2 if msa!=9999
(8 missing values generated)

. for var hhi* eg*: replace X=. if msa==9999;

->  replace hhiTcttot=. if msa==9999
(0 real changes made)

->  replace hhiTctsw=. if msa==9999
(0 real changes made)

->  replace hhiTctnsw=. if msa==9999
(0 real changes made)

->  replace hhiIcttot=. if msa==9999
(0 real changes made)

->  replace hhiIctsw=. if msa==9999
(0 real changes made)

->  replace hhiIctnsw=. if msa==9999
(0 real changes made)

->  replace hhiUcttot=. if msa==9999
(0 real changes made)

->  replace hhiUctsw=. if msa==9999
(0 real changes made)

->  replace hhiUctnsw=. if msa==9999
(0 real changes made)

->  replace hhiGcttot=. if msa==9999
(0 real changes made)

->  replace hhiGctsw=. if msa==9999
(0 real changes made)

->  replace hhiGctnsw=. if msa==9999
(0 real changes made)

->  replace hhiNcttot=. if msa==9999
(0 real changes made)

->  replace hhiNctsw=. if msa==9999
(0 real changes made)

->  replace hhiNctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC1cttot=. if msa==9999
(0 real changes made)

->  replace hhiC2cttot=. if msa==9999
(0 real changes made)

->  replace hhiC3cttot=. if msa==9999
(0 real changes made)

->  replace hhiC1ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC2ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC3ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC1ctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC2ctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC3ctnsw=. if msa==9999
(0 real changes made)

->  replace hhipop=. if msa==9999
(0 real changes made)

->  replace egTcttot=. if msa==9999
(0 real changes made)

->  replace egTctsw=. if msa==9999
(0 real changes made)

->  replace egTctnsw=. if msa==9999
(0 real changes made)

->  replace egIcttot=. if msa==9999
(0 real changes made)

->  replace egIctsw=. if msa==9999
(0 real changes made)

->  replace egIctnsw=. if msa==9999
(0 real changes made)

->  replace egUcttot=. if msa==9999
(0 real changes made)

->  replace egUctsw=. if msa==9999
(0 real changes made)

->  replace egUctnsw=. if msa==9999
(0 real changes made)

->  replace egGcttot=. if msa==9999
(0 real changes made)

->  replace egGctsw=. if msa==9999
(0 real changes made)

->  replace egGctnsw=. if msa==9999
(0 real changes made)

->  replace egNcttot=. if msa==9999
(0 real changes made)

->  replace egNctsw=. if msa==9999
(0 real changes made)

->  replace egNctnsw=. if msa==9999
(0 real changes made)

->  replace egC1cttot=. if msa==9999
(0 real changes made)

->  replace egC2cttot=. if msa==9999
(0 real changes made)

->  replace egC3cttot=. if msa==9999
(0 real changes made)

->  replace egC1ctsw=. if msa==9999
(0 real changes made)

->  replace egC2ctsw=. if msa==9999
(0 real changes made)

->  replace egC3ctsw=. if msa==9999
(0 real changes made)

->  replace egC1ctnsw=. if msa==9999
(0 real changes made)

->  replace egC2ctnsw=. if msa==9999
(0 real changes made)

->  replace egC3ctnsw=. if msa==9999
(0 real changes made)

. collapse (sum) T* I* U* G* N* C* Z* tab* hhi* eg*, by(period) fast;

. for var tabTcttot*: gen rawX=X \ replace X=X/Tcttot;

->  gen rawtabTcttot1=tabTcttot1

->  replace tabTcttot1=tabTcttot1/Tcttot
(8 real changes made)

->  gen rawtabTcttot2=tabTcttot2

->  replace tabTcttot2=tabTcttot2/Tcttot
(8 real changes made)

->  gen rawtabTcttot3=tabTcttot3

->  replace tabTcttot3=tabTcttot3/Tcttot
(8 real changes made)

->  gen rawtabTcttot4=tabTcttot4

->  replace tabTcttot4=tabTcttot4/Tcttot
(8 real changes made)

. for var tabTctsw*: gen rawX=X \ replace X=X/Tctsw;

->  gen rawtabTctsw1=tabTctsw1

->  replace tabTctsw1=tabTctsw1/Tctsw
(8 real changes made)

->  gen rawtabTctsw2=tabTctsw2

->  replace tabTctsw2=tabTctsw2/Tctsw
(8 real changes made)

->  gen rawtabTctsw3=tabTctsw3

->  replace tabTctsw3=tabTctsw3/Tctsw
(8 real changes made)

->  gen rawtabTctsw4=tabTctsw4

->  replace tabTctsw4=tabTctsw4/Tctsw
(8 real changes made)

. for var tabTctnsw*: gen rawX=X \ replace X=X/Tctnsw;

->  gen rawtabTctnsw1=tabTctnsw1

->  replace tabTctnsw1=tabTctnsw1/Tctnsw
(8 real changes made)

->  gen rawtabTctnsw2=tabTctnsw2

->  replace tabTctnsw2=tabTctnsw2/Tctnsw
(8 real changes made)

->  gen rawtabTctnsw3=tabTctnsw3

->  replace tabTctnsw3=tabTctnsw3/Tctnsw
(8 real changes made)

->  gen rawtabTctnsw4=tabTctnsw4

->  replace tabTctnsw4=tabTctnsw4/Tctnsw
(8 real changes made)

. for var eg*: replace X=X/(1-hhipop);

->  replace egTcttot=egTcttot/(1-hhipop)
(8 real changes made)

->  replace egTctsw=egTctsw/(1-hhipop)
(8 real changes made)

->  replace egTctnsw=egTctnsw/(1-hhipop)
(8 real changes made)

->  replace egIcttot=egIcttot/(1-hhipop)
(8 real changes made)

->  replace egIctsw=egIctsw/(1-hhipop)
(8 real changes made)

->  replace egIctnsw=egIctnsw/(1-hhipop)
(8 real changes made)

->  replace egUcttot=egUcttot/(1-hhipop)
(8 real changes made)

->  replace egUctsw=egUctsw/(1-hhipop)
(8 real changes made)

->  replace egUctnsw=egUctnsw/(1-hhipop)
(8 real changes made)

->  replace egGcttot=egGcttot/(1-hhipop)
(8 real changes made)

->  replace egGctsw=egGctsw/(1-hhipop)
(8 real changes made)

->  replace egGctnsw=egGctnsw/(1-hhipop)
(8 real changes made)

->  replace egNcttot=egNcttot/(1-hhipop)
(8 real changes made)

->  replace egNctsw=egNctsw/(1-hhipop)
(8 real changes made)

->  replace egNctnsw=egNctnsw/(1-hhipop)
(8 real changes made)

->  replace egC1cttot=egC1cttot/(1-hhipop)
(8 real changes made)

->  replace egC2cttot=egC2cttot/(1-hhipop)
(8 real changes made)

->  replace egC3cttot=egC3cttot/(1-hhipop)
(8 real changes made)

->  replace egC1ctsw=egC1ctsw/(1-hhipop)
(8 real changes made)

->  replace egC2ctsw=egC2ctsw/(1-hhipop)
(8 real changes made)

->  replace egC3ctsw=egC3ctsw/(1-hhipop)
(8 real changes made)

->  replace egC1ctnsw=egC1ctnsw/(1-hhipop)
(8 real changes made)

->  replace egC2ctnsw=egC2ctnsw/(1-hhipop)
(8 real changes made)

->  replace egC3ctnsw=egC3ctnsw/(1-hhipop)
(8 real changes made)

. for any T I U G N C1 C2 C3: gen shswX=100*Xctsw/Xcttot;

->  gen shswT=100*Tctsw/Tcttot

->  gen shswI=100*Ictsw/Icttot

->  gen shswU=100*Uctsw/Ucttot

->  gen shswG=100*Gctsw/Gcttot

->  gen shswN=100*Nctsw/Ncttot

->  gen shswC1=100*C1ctsw/C1cttot

->  gen shswC2=100*C2ctsw/C2cttot

->  gen shswC3=100*C3ctsw/C3cttot

. format tab* eg* hhi* %4.3f;

.  format sh* %3.2f;

.  format raw* %8.0f;

.  * Table S10a - Equivalent to Figure 2 & Table S2;
. for any tot sw nsw:
> list period tabTctX*, clean noobs;

->  list period tabTcttot*, clean noobs

    period   tabTc~t1   tabTc~t2   tabTc~t3   tabTc~t4  
      1975      0.113      0.322      0.455      0.110  
      1980      0.124      0.298      0.468      0.110  
      1985      0.139      0.276      0.478      0.107  
      1990      0.163      0.252      0.485      0.100  
      1995      0.233      0.220      0.463      0.084  
      2000      0.274      0.202      0.448      0.077  
      2005      0.307      0.198      0.428      0.067  
      2010      0.323      0.195      0.415      0.067  

->  list period tabTctsw*, clean noobs

    period   tab~tsw1   tab~tsw2   tab~tsw3   tab~tsw4  
      1975      0.183      0.324      0.422      0.071  
      1980      0.200      0.291      0.442      0.066  
      1985      0.228      0.256      0.445      0.070  
      1990      0.270      0.223      0.450      0.056  
      1995      0.360      0.187      0.409      0.044  
      2000      0.396      0.172      0.393      0.039  
      2005      0.424      0.175      0.367      0.033  
      2010      0.449      0.174      0.346      0.031  

->  list period tabTctnsw*, clean noobs

    period   tab~nsw1   tab~nsw2   tab~nsw3   tab~nsw4  
      1975      0.097      0.322      0.462      0.119  
      1980      0.104      0.300      0.474      0.122  
      1985      0.113      0.281      0.488      0.118  
      1990      0.125      0.262      0.497      0.116  
      1995      0.157      0.240      0.496      0.107  
      2000      0.172      0.227      0.494      0.108  
      2005      0.183      0.222      0.493      0.102  
      2010      0.193      0.217      0.486      0.105  

. * Table S11a - Equivalent to Table S3;
. for any T:
> list period Xcttot Xctsw shswX hhiXcttot hhiXctsw hhiXctnsw egXcttot egXctsw egXctnsw, clean noobs;

->  list period Tcttot Tctsw shswT hhiTcttot hhiTctsw hhiTctnsw egTcttot egTctsw egTctnsw, clean noobs

    period   Tcttot    Tctsw   shswT   hhiTct~t   hhiTctsw   hhiT~nsw   egTcttot   egTctsw   egTctnsw  
      1975   197891    36200   18.29      0.041      0.050      0.039      0.003     0.009      0.003  
      1980   181181    37687   20.80      0.037      0.045      0.036      0.003     0.009      0.003  
      1985   214429    48666   22.70      0.034      0.044      0.033      0.003     0.011      0.003  
      1990   293466    77971   26.57      0.032      0.048      0.030      0.005     0.019      0.003  
      1995   443307   165500   37.33      0.039      0.071      0.030      0.013     0.042      0.005  
      2000   525416   238531   45.40      0.045      0.076      0.031      0.020     0.050      0.007  
      2005   493712   254707   51.59      0.049      0.079      0.031      0.024     0.052      0.008  
      2010   303394   154871   51.05      0.056      0.095      0.032      0.030     0.067      0.009  

. *********************************;
. *** Core ML Analysis         ***;
. *********************************;
. use if software_ml!=. using patent-spatial-final1, clear;

. drop gyear ayear num_claims backward forward fw_selfcite originality generality dENG-dVNM uspc*;

. * Organize patents and institutions;
. gen Tcttot=1;

.  gen Tctsw=software_ml;

.  gen Tctnsw=1-software_ml;

. for any cttot ctsw ctnsw: gen IX=TX if ind==1 \ gen UX=TX if univ==1 \ gen GX=TX if gov==1 \ gen NX=TX if (ind==0 & gov==0 & univ==0
> );

->  gen Icttot=Tcttot if ind==1
(681,040 missing values generated)

->  gen Ucttot=Tcttot if univ==1
(3,361,822 missing values generated)

->  gen Gcttot=Tcttot if gov==1
(3,457,872 missing values generated)

->  gen Ncttot=Tcttot if (ind==0 & gov==0 & univ==0)
(2,976,349 missing values generated)

->  gen Ictsw=Tctsw if ind==1
(681,040 missing values generated)

->  gen Uctsw=Tctsw if univ==1
(3,361,822 missing values generated)

->  gen Gctsw=Tctsw if gov==1
(3,457,872 missing values generated)

->  gen Nctsw=Tctsw if (ind==0 & gov==0 & univ==0)
(2,976,349 missing values generated)

->  gen Ictnsw=Tctnsw if ind==1
(681,040 missing values generated)

->  gen Uctnsw=Tctnsw if univ==1
(3,361,822 missing values generated)

->  gen Gctnsw=Tctnsw if gov==1
(3,457,872 missing values generated)

->  gen Nctnsw=Tctnsw if (ind==0 & gov==0 & univ==0)
(2,976,349 missing values generated)

. for any cttot ctsw ctnsw: gen C1X=TX if (nber_cat==2 | nber_cat==4) \ gen C2X=TX if (nber_cat==1 | nber_cat==3) \ gen C3X=TX if (nbe
> r_cat==5 | nber_cat==6);

->  gen C1cttot=Tcttot if (nber_cat==2 | nber_cat==4)
(1,934,751 missing values generated)

->  gen C2cttot=Tcttot if (nber_cat==1 | nber_cat==3)
(2,626,698 missing values generated)

->  gen C3cttot=Tcttot if (nber_cat==5 | nber_cat==6)
(2,434,039 missing values generated)

->  gen C1ctsw=Tctsw if (nber_cat==2 | nber_cat==4)
(1,934,751 missing values generated)

->  gen C2ctsw=Tctsw if (nber_cat==1 | nber_cat==3)
(2,626,698 missing values generated)

->  gen C3ctsw=Tctsw if (nber_cat==5 | nber_cat==6)
(2,434,039 missing values generated)

->  gen C1ctnsw=Tctnsw if (nber_cat==2 | nber_cat==4)
(1,934,751 missing values generated)

->  gen C2ctnsw=Tctnsw if (nber_cat==1 | nber_cat==3)
(2,626,698 missing values generated)

->  gen C3ctnsw=Tctnsw if (nber_cat==5 | nber_cat==6)
(2,434,039 missing values generated)

. for num 1/6: gen ZXctsw=Tctsw if nber_cat==X \ gen ZXctnsw=Tctnsw if nber_cat==X;

->  gen Z1ctsw=Tctsw if nber_cat==1
(3,068,973 missing values generated)

->  gen Z1ctnsw=Tctnsw if nber_cat==1
(3,068,973 missing values generated)

->  gen Z2ctsw=Tctsw if nber_cat==2
(2,534,507 missing values generated)

->  gen Z2ctnsw=Tctnsw if nber_cat==2
(2,534,507 missing values generated)

->  gen Z3ctsw=Tctsw if nber_cat==3
(3,055,469 missing values generated)

->  gen Z3ctnsw=Tctnsw if nber_cat==3
(3,055,469 missing values generated)

->  gen Z4ctsw=Tctsw if nber_cat==4
(2,897,988 missing values generated)

->  gen Z4ctnsw=Tctnsw if nber_cat==4
(2,897,988 missing values generated)

->  gen Z5ctsw=Tctsw if nber_cat==5
(3,017,281 missing values generated)

->  gen Z5ctnsw=Tctnsw if nber_cat==5
(3,017,281 missing values generated)

->  gen Z6ctsw=Tctsw if nber_cat==6
(2,914,502 missing values generated)

->  gen Z6ctnsw=Tctnsw if nber_cat==6
(2,914,502 missing values generated)

. * Collapse on MSA-period cells and merge population data;
. * Prepare a zero-valued observation for 7000 in 1980;
. * Fix pop min for early years of 380 (Anchorage AK) and 3320 (Honolulu HI);
. collapse (sum) T* I* U* G* N* C* Z* (mean) cluster, by(msa period) fast;

. sort msa period;

.  merge msa period using period_population_msa;
(note: you are using old merge syntax; see [D] merge for new syntax)

. tab _m;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |          8        0.32        0.32
          2 |          1        0.04        0.35
          3 |      2,529       99.65      100.00
------------+-----------------------------------
      Total |      2,538      100.00

.  table msa _m if _m!=3;

----------------------
          |   _merge  
      msa |    1     2
----------+-----------
      380 |    3      
     3320 |    5      
     7000 |          1
----------------------

.  ren pop pop;

.  for var T* I* U* G* N* C* Z*: replace X=0 if _m==2;

->  replace Tcttot=0 if _m==2
(1 real change made)

->  replace Tctsw=0 if _m==2
(1 real change made)

->  replace Tctnsw=0 if _m==2
(1 real change made)

->  replace Icttot=0 if _m==2
(1 real change made)

->  replace Ictsw=0 if _m==2
(1 real change made)

->  replace Ictnsw=0 if _m==2
(1 real change made)

->  replace Ucttot=0 if _m==2
(1 real change made)

->  replace Uctsw=0 if _m==2
(1 real change made)

->  replace Uctnsw=0 if _m==2
(1 real change made)

->  replace Gcttot=0 if _m==2
(1 real change made)

->  replace Gctsw=0 if _m==2
(1 real change made)

->  replace Gctnsw=0 if _m==2
(1 real change made)

->  replace Ncttot=0 if _m==2
(1 real change made)

->  replace Nctsw=0 if _m==2
(1 real change made)

->  replace Nctnsw=0 if _m==2
(1 real change made)

->  replace C1cttot=0 if _m==2
(1 real change made)

->  replace C2cttot=0 if _m==2
(1 real change made)

->  replace C3cttot=0 if _m==2
(1 real change made)

->  replace C1ctsw=0 if _m==2
(1 real change made)

->  replace C2ctsw=0 if _m==2
(1 real change made)

->  replace C3ctsw=0 if _m==2
(1 real change made)

->  replace C1ctnsw=0 if _m==2
(1 real change made)

->  replace C2ctnsw=0 if _m==2
(1 real change made)

->  replace C3ctnsw=0 if _m==2
(1 real change made)

->  replace Z1ctsw=0 if _m==2
(1 real change made)

->  replace Z1ctnsw=0 if _m==2
(1 real change made)

->  replace Z2ctsw=0 if _m==2
(1 real change made)

->  replace Z2ctnsw=0 if _m==2
(1 real change made)

->  replace Z3ctsw=0 if _m==2
(1 real change made)

->  replace Z3ctnsw=0 if _m==2
(1 real change made)

->  replace Z4ctsw=0 if _m==2
(1 real change made)

->  replace Z4ctnsw=0 if _m==2
(1 real change made)

->  replace Z5ctsw=0 if _m==2
(1 real change made)

->  replace Z5ctnsw=0 if _m==2
(1 real change made)

->  replace Z6ctsw=0 if _m==2
(1 real change made)

->  replace Z6ctnsw=0 if _m==2
(1 real change made)

. egen temp1=min(pop), by(msa);

.  replace pop=temp1 if _m==1;
(8 real changes made)

.  drop _m temp1;

. * Generate HHI and EG components and collapse;
. for var T*: gen tabX1=X if cluster==1 \ gen tabX2=X if cluster==2 \ gen tabX3=X if cluster==3 \ gen tabX4=X if cluster==4;

->  gen tabTcttot1=Tcttot if cluster==1
(2,484 missing values generated)

->  gen tabTcttot2=Tcttot if cluster==2
(2,493 missing values generated)

->  gen tabTcttot3=Tcttot if cluster==3
(109 missing values generated)

->  gen tabTcttot4=Tcttot if cluster==4
(2,529 missing values generated)

->  gen tabTctsw1=Tctsw if cluster==1
(2,484 missing values generated)

->  gen tabTctsw2=Tctsw if cluster==2
(2,493 missing values generated)

->  gen tabTctsw3=Tctsw if cluster==3
(109 missing values generated)

->  gen tabTctsw4=Tctsw if cluster==4
(2,529 missing values generated)

->  gen tabTctnsw1=Tctnsw if cluster==1
(2,484 missing values generated)

->  gen tabTctnsw2=Tctnsw if cluster==2
(2,493 missing values generated)

->  gen tabTctnsw3=Tctnsw if cluster==3
(109 missing values generated)

->  gen tabTctnsw4=Tctnsw if cluster==4
(2,529 missing values generated)

. for var T* I* U* G* N* C* pop:
> \ gen temp1=X if msa!=9999 \ egen sumX=sum(temp1), by(period) \ gen shX=X/sumX if msa!=9999  \ drop sumX temp1;

-> 

->  gen temp1=Tcttot if msa!=9999
(9 missing values generated)

->  egen sumTcttot=sum(temp1), by(period)

->  gen shTcttot=Tcttot/sumTcttot if msa!=9999
(9 missing values generated)

->  drop sumTcttot temp1

-> 

->  gen temp1=Tctsw if msa!=9999
(9 missing values generated)

->  egen sumTctsw=sum(temp1), by(period)

->  gen shTctsw=Tctsw/sumTctsw if msa!=9999
(9 missing values generated)

->  drop sumTctsw temp1

-> 

->  gen temp1=Tctnsw if msa!=9999
(9 missing values generated)

->  egen sumTctnsw=sum(temp1), by(period)

->  gen shTctnsw=Tctnsw/sumTctnsw if msa!=9999
(9 missing values generated)

->  drop sumTctnsw temp1

-> 

->  gen temp1=Icttot if msa!=9999
(9 missing values generated)

->  egen sumIcttot=sum(temp1), by(period)

->  gen shIcttot=Icttot/sumIcttot if msa!=9999
(9 missing values generated)

->  drop sumIcttot temp1

-> 

->  gen temp1=Ictsw if msa!=9999
(9 missing values generated)

->  egen sumIctsw=sum(temp1), by(period)

->  gen shIctsw=Ictsw/sumIctsw if msa!=9999
(9 missing values generated)

->  drop sumIctsw temp1

-> 

->  gen temp1=Ictnsw if msa!=9999
(9 missing values generated)

->  egen sumIctnsw=sum(temp1), by(period)

->  gen shIctnsw=Ictnsw/sumIctnsw if msa!=9999
(9 missing values generated)

->  drop sumIctnsw temp1

-> 

->  gen temp1=Ucttot if msa!=9999
(9 missing values generated)

->  egen sumUcttot=sum(temp1), by(period)

->  gen shUcttot=Ucttot/sumUcttot if msa!=9999
(9 missing values generated)

->  drop sumUcttot temp1

-> 

->  gen temp1=Uctsw if msa!=9999
(9 missing values generated)

->  egen sumUctsw=sum(temp1), by(period)

->  gen shUctsw=Uctsw/sumUctsw if msa!=9999
(9 missing values generated)

->  drop sumUctsw temp1

-> 

->  gen temp1=Uctnsw if msa!=9999
(9 missing values generated)

->  egen sumUctnsw=sum(temp1), by(period)

->  gen shUctnsw=Uctnsw/sumUctnsw if msa!=9999
(9 missing values generated)

->  drop sumUctnsw temp1

-> 

->  gen temp1=Gcttot if msa!=9999
(9 missing values generated)

->  egen sumGcttot=sum(temp1), by(period)

->  gen shGcttot=Gcttot/sumGcttot if msa!=9999
(9 missing values generated)

->  drop sumGcttot temp1

-> 

->  gen temp1=Gctsw if msa!=9999
(9 missing values generated)

->  egen sumGctsw=sum(temp1), by(period)

->  gen shGctsw=Gctsw/sumGctsw if msa!=9999
(9 missing values generated)

->  drop sumGctsw temp1

-> 

->  gen temp1=Gctnsw if msa!=9999
(9 missing values generated)

->  egen sumGctnsw=sum(temp1), by(period)

->  gen shGctnsw=Gctnsw/sumGctnsw if msa!=9999
(9 missing values generated)

->  drop sumGctnsw temp1

-> 

->  gen temp1=Ncttot if msa!=9999
(9 missing values generated)

->  egen sumNcttot=sum(temp1), by(period)

->  gen shNcttot=Ncttot/sumNcttot if msa!=9999
(9 missing values generated)

->  drop sumNcttot temp1

-> 

->  gen temp1=Nctsw if msa!=9999
(9 missing values generated)

->  egen sumNctsw=sum(temp1), by(period)

->  gen shNctsw=Nctsw/sumNctsw if msa!=9999
(9 missing values generated)

->  drop sumNctsw temp1

-> 

->  gen temp1=Nctnsw if msa!=9999
(9 missing values generated)

->  egen sumNctnsw=sum(temp1), by(period)

->  gen shNctnsw=Nctnsw/sumNctnsw if msa!=9999
(9 missing values generated)

->  drop sumNctnsw temp1

-> 

->  gen temp1=C1cttot if msa!=9999
(9 missing values generated)

->  egen sumC1cttot=sum(temp1), by(period)

->  gen shC1cttot=C1cttot/sumC1cttot if msa!=9999
(9 missing values generated)

->  drop sumC1cttot temp1

-> 

->  gen temp1=C2cttot if msa!=9999
(9 missing values generated)

->  egen sumC2cttot=sum(temp1), by(period)

->  gen shC2cttot=C2cttot/sumC2cttot if msa!=9999
(9 missing values generated)

->  drop sumC2cttot temp1

-> 

->  gen temp1=C3cttot if msa!=9999
(9 missing values generated)

->  egen sumC3cttot=sum(temp1), by(period)

->  gen shC3cttot=C3cttot/sumC3cttot if msa!=9999
(9 missing values generated)

->  drop sumC3cttot temp1

-> 

->  gen temp1=C1ctsw if msa!=9999
(9 missing values generated)

->  egen sumC1ctsw=sum(temp1), by(period)

->  gen shC1ctsw=C1ctsw/sumC1ctsw if msa!=9999
(9 missing values generated)

->  drop sumC1ctsw temp1

-> 

->  gen temp1=C2ctsw if msa!=9999
(9 missing values generated)

->  egen sumC2ctsw=sum(temp1), by(period)

->  gen shC2ctsw=C2ctsw/sumC2ctsw if msa!=9999
(9 missing values generated)

->  drop sumC2ctsw temp1

-> 

->  gen temp1=C3ctsw if msa!=9999
(9 missing values generated)

->  egen sumC3ctsw=sum(temp1), by(period)

->  gen shC3ctsw=C3ctsw/sumC3ctsw if msa!=9999
(9 missing values generated)

->  drop sumC3ctsw temp1

-> 

->  gen temp1=C1ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC1ctnsw=sum(temp1), by(period)

->  gen shC1ctnsw=C1ctnsw/sumC1ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC1ctnsw temp1

-> 

->  gen temp1=C2ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC2ctnsw=sum(temp1), by(period)

->  gen shC2ctnsw=C2ctnsw/sumC2ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC2ctnsw temp1

-> 

->  gen temp1=C3ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC3ctnsw=sum(temp1), by(period)

->  gen shC3ctnsw=C3ctnsw/sumC3ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC3ctnsw temp1

-> 

->  gen temp1=pop if msa!=9999
(9 missing values generated)

->  egen sumpop=sum(temp1), by(period)

->  gen shpop=pop/sumpop if msa!=9999
(9 missing values generated)

->  drop sumpop temp1

. for var T* I* U* G* N* C* pop: gen hhiX=shX^2 if msa!=9999;

->  gen hhiTcttot=shTcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiTctsw=shTctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiTctnsw=shTctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiIcttot=shIcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiIctsw=shIctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiIctnsw=shIctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiUcttot=shUcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiUctsw=shUctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiUctnsw=shUctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiGcttot=shGcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiGctsw=shGctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiGctnsw=shGctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiNcttot=shNcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiNctsw=shNctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiNctnsw=shNctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC1cttot=shC1cttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiC2cttot=shC2cttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiC3cttot=shC3cttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiC1ctsw=shC1ctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC2ctsw=shC2ctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC3ctsw=shC3ctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC1ctnsw=shC1ctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC2ctnsw=shC2ctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC3ctnsw=shC3ctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhipop=shpop^2 if msa!=9999
(9 missing values generated)

. for var T* I* U* G* N* C*: gen egX=(shX-shpop)^2 if msa!=9999;

->  gen egTcttot=(shTcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egTctsw=(shTctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egTctnsw=(shTctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egIcttot=(shIcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egIctsw=(shIctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egIctnsw=(shIctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egUcttot=(shUcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egUctsw=(shUctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egUctnsw=(shUctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egGcttot=(shGcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egGctsw=(shGctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egGctnsw=(shGctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egNcttot=(shNcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egNctsw=(shNctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egNctnsw=(shNctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC1cttot=(shC1cttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC2cttot=(shC2cttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC3cttot=(shC3cttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC1ctsw=(shC1ctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC2ctsw=(shC2ctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC3ctsw=(shC3ctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC1ctnsw=(shC1ctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC2ctnsw=(shC2ctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC3ctnsw=(shC3ctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

. for var hhi* eg*: replace X=. if msa==9999;

->  replace hhiTcttot=. if msa==9999
(0 real changes made)

->  replace hhiTctsw=. if msa==9999
(0 real changes made)

->  replace hhiTctnsw=. if msa==9999
(0 real changes made)

->  replace hhiIcttot=. if msa==9999
(0 real changes made)

->  replace hhiIctsw=. if msa==9999
(0 real changes made)

->  replace hhiIctnsw=. if msa==9999
(0 real changes made)

->  replace hhiUcttot=. if msa==9999
(0 real changes made)

->  replace hhiUctsw=. if msa==9999
(0 real changes made)

->  replace hhiUctnsw=. if msa==9999
(0 real changes made)

->  replace hhiGcttot=. if msa==9999
(0 real changes made)

->  replace hhiGctsw=. if msa==9999
(0 real changes made)

->  replace hhiGctnsw=. if msa==9999
(0 real changes made)

->  replace hhiNcttot=. if msa==9999
(0 real changes made)

->  replace hhiNctsw=. if msa==9999
(0 real changes made)

->  replace hhiNctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC1cttot=. if msa==9999
(0 real changes made)

->  replace hhiC2cttot=. if msa==9999
(0 real changes made)

->  replace hhiC3cttot=. if msa==9999
(0 real changes made)

->  replace hhiC1ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC2ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC3ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC1ctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC2ctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC3ctnsw=. if msa==9999
(0 real changes made)

->  replace hhipop=. if msa==9999
(0 real changes made)

->  replace egTcttot=. if msa==9999
(0 real changes made)

->  replace egTctsw=. if msa==9999
(0 real changes made)

->  replace egTctnsw=. if msa==9999
(0 real changes made)

->  replace egIcttot=. if msa==9999
(0 real changes made)

->  replace egIctsw=. if msa==9999
(0 real changes made)

->  replace egIctnsw=. if msa==9999
(0 real changes made)

->  replace egUcttot=. if msa==9999
(0 real changes made)

->  replace egUctsw=. if msa==9999
(0 real changes made)

->  replace egUctnsw=. if msa==9999
(0 real changes made)

->  replace egGcttot=. if msa==9999
(0 real changes made)

->  replace egGctsw=. if msa==9999
(0 real changes made)

->  replace egGctnsw=. if msa==9999
(0 real changes made)

->  replace egNcttot=. if msa==9999
(0 real changes made)

->  replace egNctsw=. if msa==9999
(0 real changes made)

->  replace egNctnsw=. if msa==9999
(0 real changes made)

->  replace egC1cttot=. if msa==9999
(0 real changes made)

->  replace egC2cttot=. if msa==9999
(0 real changes made)

->  replace egC3cttot=. if msa==9999
(0 real changes made)

->  replace egC1ctsw=. if msa==9999
(0 real changes made)

->  replace egC2ctsw=. if msa==9999
(0 real changes made)

->  replace egC3ctsw=. if msa==9999
(0 real changes made)

->  replace egC1ctnsw=. if msa==9999
(0 real changes made)

->  replace egC2ctnsw=. if msa==9999
(0 real changes made)

->  replace egC3ctnsw=. if msa==9999
(0 real changes made)

. collapse (sum) T* I* U* G* N* C* Z* tab* hhi* eg*, by(period) fast;

. for var tabTcttot*: gen rawX=X \ replace X=X/Tcttot;

->  gen rawtabTcttot1=tabTcttot1

->  replace tabTcttot1=tabTcttot1/Tcttot
(9 real changes made)

->  gen rawtabTcttot2=tabTcttot2

->  replace tabTcttot2=tabTcttot2/Tcttot
(9 real changes made)

->  gen rawtabTcttot3=tabTcttot3

->  replace tabTcttot3=tabTcttot3/Tcttot
(9 real changes made)

->  gen rawtabTcttot4=tabTcttot4

->  replace tabTcttot4=tabTcttot4/Tcttot
(9 real changes made)

. for var tabTctsw*: gen rawX=X \ replace X=X/Tctsw;

->  gen rawtabTctsw1=tabTctsw1

->  replace tabTctsw1=tabTctsw1/Tctsw
(9 real changes made)

->  gen rawtabTctsw2=tabTctsw2

->  replace tabTctsw2=tabTctsw2/Tctsw
(9 real changes made)

->  gen rawtabTctsw3=tabTctsw3

->  replace tabTctsw3=tabTctsw3/Tctsw
(9 real changes made)

->  gen rawtabTctsw4=tabTctsw4

->  replace tabTctsw4=tabTctsw4/Tctsw
(9 real changes made)

. for var tabTctnsw*: gen rawX=X \ replace X=X/Tctnsw;

->  gen rawtabTctnsw1=tabTctnsw1

->  replace tabTctnsw1=tabTctnsw1/Tctnsw
(9 real changes made)

->  gen rawtabTctnsw2=tabTctnsw2

->  replace tabTctnsw2=tabTctnsw2/Tctnsw
(9 real changes made)

->  gen rawtabTctnsw3=tabTctnsw3

->  replace tabTctnsw3=tabTctnsw3/Tctnsw
(9 real changes made)

->  gen rawtabTctnsw4=tabTctnsw4

->  replace tabTctnsw4=tabTctnsw4/Tctnsw
(9 real changes made)

. for var eg*: replace X=X/(1-hhipop);

->  replace egTcttot=egTcttot/(1-hhipop)
(9 real changes made)

->  replace egTctsw=egTctsw/(1-hhipop)
(9 real changes made)

->  replace egTctnsw=egTctnsw/(1-hhipop)
(9 real changes made)

->  replace egIcttot=egIcttot/(1-hhipop)
(9 real changes made)

->  replace egIctsw=egIctsw/(1-hhipop)
(9 real changes made)

->  replace egIctnsw=egIctnsw/(1-hhipop)
(9 real changes made)

->  replace egUcttot=egUcttot/(1-hhipop)
(9 real changes made)

->  replace egUctsw=egUctsw/(1-hhipop)
(9 real changes made)

->  replace egUctnsw=egUctnsw/(1-hhipop)
(9 real changes made)

->  replace egGcttot=egGcttot/(1-hhipop)
(9 real changes made)

->  replace egGctsw=egGctsw/(1-hhipop)
(9 real changes made)

->  replace egGctnsw=egGctnsw/(1-hhipop)
(9 real changes made)

->  replace egNcttot=egNcttot/(1-hhipop)
(9 real changes made)

->  replace egNctsw=egNctsw/(1-hhipop)
(9 real changes made)

->  replace egNctnsw=egNctnsw/(1-hhipop)
(9 real changes made)

->  replace egC1cttot=egC1cttot/(1-hhipop)
(9 real changes made)

->  replace egC2cttot=egC2cttot/(1-hhipop)
(9 real changes made)

->  replace egC3cttot=egC3cttot/(1-hhipop)
(9 real changes made)

->  replace egC1ctsw=egC1ctsw/(1-hhipop)
(9 real changes made)

->  replace egC2ctsw=egC2ctsw/(1-hhipop)
(9 real changes made)

->  replace egC3ctsw=egC3ctsw/(1-hhipop)
(9 real changes made)

->  replace egC1ctnsw=egC1ctnsw/(1-hhipop)
(9 real changes made)

->  replace egC2ctnsw=egC2ctnsw/(1-hhipop)
(9 real changes made)

->  replace egC3ctnsw=egC3ctnsw/(1-hhipop)
(9 real changes made)

. for any T I U G N C1 C2 C3: gen shswX=100*Xctsw/Xcttot;

->  gen shswT=100*Tctsw/Tcttot

->  gen shswI=100*Ictsw/Icttot

->  gen shswU=100*Uctsw/Ucttot

->  gen shswG=100*Gctsw/Gcttot

->  gen shswN=100*Nctsw/Ncttot

->  gen shswC1=100*C1ctsw/C1cttot

->  gen shswC2=100*C2ctsw/C2cttot

->  gen shswC3=100*C3ctsw/C3cttot

. format tab* eg* hhi* %4.3f;

.  format sh* %3.2f;

.  format raw* %8.0f;

.  * Table S10b - Equivalent to Figure 2 & Table S2;
. for any tot sw nsw:
> list period tabTctX*, clean noobs;

->  list period tabTcttot*, clean noobs

    period   tabTc~t1   tabTc~t2   tabTc~t3   tabTc~t4  
      1975      0.113      0.322      0.455      0.110  
      1980      0.124      0.298      0.468      0.110  
      1985      0.139      0.276      0.478      0.107  
      1990      0.163      0.252      0.485      0.100  
      1995      0.233      0.220      0.463      0.084  
      2000      0.274      0.202      0.448      0.076  
      2005      0.310      0.198      0.427      0.066  
      2010      0.337      0.189      0.413      0.062  
      2015      0.342      0.186      0.410      0.061  

->  list period tabTctsw*, clean noobs

    period   tab~tsw1   tab~tsw2   tab~tsw3   tab~tsw4  
      1975      0.160      0.348      0.424      0.068  
      1980      0.195      0.315      0.432      0.057  
      1985      0.231      0.293      0.413      0.063  
      1990      0.278      0.260      0.411      0.052  
      1995      0.364      0.217      0.378      0.041  
      2000      0.400      0.195      0.368      0.037  
      2005      0.425      0.190      0.349      0.036  
      2010      0.459      0.179      0.327      0.035  
      2015      0.461      0.176      0.328      0.036  

->  list period tabTctnsw*, clean noobs

    period   tab~nsw1   tab~nsw2   tab~nsw3   tab~nsw4  
      1975      0.109      0.320      0.457      0.114  
      1980      0.117      0.296      0.471      0.116  
      1985      0.128      0.274      0.486      0.112  
      1990      0.141      0.250      0.499      0.110  
      1995      0.182      0.222      0.496      0.100  
      2000      0.209      0.205      0.489      0.097  
      2005      0.227      0.203      0.482      0.087  
      2010      0.238      0.197      0.482      0.083  
      2015      0.242      0.195      0.480      0.083  

. * Table S11b - Equivalent to Table S3;
. for any T:
> list period Xcttot Xctsw shswX hhiXcttot hhiXctsw hhiXctnsw egXcttot egXctsw egXctnsw, clean noobs;

->  list period Tcttot Tctsw shswT hhiTcttot hhiTctsw hhiTctnsw egTcttot egTctsw egTctnsw, clean noobs

    period   Tcttot    Tctsw   shswT   hhiTct~t   hhiTctsw   hhiT~nsw   egTcttot   egTctsw   egTctnsw  
      1975   197888    13549    6.85      0.041      0.052      0.040      0.003     0.009      0.003  
      1980   181204    16072    8.87      0.037      0.049      0.036      0.003     0.010      0.003  
      1985   214518    23926   11.15      0.034      0.047      0.033      0.003     0.011      0.003  
      1990   293533    48792   16.62      0.032      0.048      0.030      0.005     0.016      0.004  
      1995   443555   123657   27.88      0.039      0.062      0.033      0.013     0.032      0.008  
      2000   526479   178614   33.93      0.045      0.067      0.037      0.020     0.039      0.014  
      2005   515688   214965   41.69      0.050      0.072      0.039      0.025     0.044      0.016  
      2010   630822   280922   44.53      0.057      0.089      0.039      0.032     0.061      0.016  
      2015   494057   225945   45.73      0.058      0.092      0.039      0.033     0.063      0.016  

. *********************************;
. *** ML Extra Analysis Text    ***;
. *********************************;
. use if software_ml!=. using patent-spatial-final1, clear;

. gen Tct00=(probability>0 & probability<=.1);

. gen Tct10=(probability>0.1 & probability<=.8);

. gen Tct80=(probability>0.8 & probability<=1);

. gen Tcttot=1;

.  sum Tct*;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       Tct00 |  3,497,744    .5717471    .4948256          0          1
       Tct10 |  3,497,744     .174847    .3798362          0          1
       Tct80 |  3,497,744    .2534059    .4349614          0          1
      Tcttot |  3,497,744           1           0          1          1

. * Collapse on MSA-period cells and merge population data;
. collapse (sum) T* (mean) cluster, by(msa period) fast;

. sort msa period;

.  merge msa period using period_population_msa;
(note: you are using old merge syntax; see [D] merge for new syntax)

. tab _m;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |          8        0.32        0.32
          2 |          1        0.04        0.35
          3 |      2,529       99.65      100.00
------------+-----------------------------------
      Total |      2,538      100.00

.  table msa _m if _m!=3;

----------------------
          |   _merge  
      msa |    1     2
----------+-----------
      380 |    3      
     3320 |    5      
     7000 |          1
----------------------

.  ren pop pop;

.  for var T*: replace X=0 if _m==2;

->  replace Tct00=0 if _m==2
(1 real change made)

->  replace Tct10=0 if _m==2
(1 real change made)

->  replace Tct80=0 if _m==2
(1 real change made)

->  replace Tcttot=0 if _m==2
(1 real change made)

. egen temp1=min(pop), by(msa);

.  replace pop=temp1 if _m==1;
(8 real changes made)

.  drop _m temp1;

. * Generate HHI and EG components and collapse;
. for var T*: gen tabX1=X if cluster==1 \ gen tabX2=X if cluster==2 \ gen tabX3=X if cluster==3 \ gen tabX4=X if cluster==4;

->  gen tabTct001=Tct00 if cluster==1
(2,484 missing values generated)

->  gen tabTct002=Tct00 if cluster==2
(2,493 missing values generated)

->  gen tabTct003=Tct00 if cluster==3
(109 missing values generated)

->  gen tabTct004=Tct00 if cluster==4
(2,529 missing values generated)

->  gen tabTct101=Tct10 if cluster==1
(2,484 missing values generated)

->  gen tabTct102=Tct10 if cluster==2
(2,493 missing values generated)

->  gen tabTct103=Tct10 if cluster==3
(109 missing values generated)

->  gen tabTct104=Tct10 if cluster==4
(2,529 missing values generated)

->  gen tabTct801=Tct80 if cluster==1
(2,484 missing values generated)

->  gen tabTct802=Tct80 if cluster==2
(2,493 missing values generated)

->  gen tabTct803=Tct80 if cluster==3
(109 missing values generated)

->  gen tabTct804=Tct80 if cluster==4
(2,529 missing values generated)

->  gen tabTcttot1=Tcttot if cluster==1
(2,484 missing values generated)

->  gen tabTcttot2=Tcttot if cluster==2
(2,493 missing values generated)

->  gen tabTcttot3=Tcttot if cluster==3
(109 missing values generated)

->  gen tabTcttot4=Tcttot if cluster==4
(2,529 missing values generated)

. for var T* pop:
> \ gen temp1=X if msa!=9999 \ egen sumX=sum(temp1), by(period) \ gen shX=X/sumX if msa!=9999  \ drop sumX temp1;

-> 

->  gen temp1=Tct00 if msa!=9999
(9 missing values generated)

->  egen sumTct00=sum(temp1), by(period)

->  gen shTct00=Tct00/sumTct00 if msa!=9999
(9 missing values generated)

->  drop sumTct00 temp1

-> 

->  gen temp1=Tct10 if msa!=9999
(9 missing values generated)

->  egen sumTct10=sum(temp1), by(period)

->  gen shTct10=Tct10/sumTct10 if msa!=9999
(9 missing values generated)

->  drop sumTct10 temp1

-> 

->  gen temp1=Tct80 if msa!=9999
(9 missing values generated)

->  egen sumTct80=sum(temp1), by(period)

->  gen shTct80=Tct80/sumTct80 if msa!=9999
(9 missing values generated)

->  drop sumTct80 temp1

-> 

->  gen temp1=Tcttot if msa!=9999
(9 missing values generated)

->  egen sumTcttot=sum(temp1), by(period)

->  gen shTcttot=Tcttot/sumTcttot if msa!=9999
(9 missing values generated)

->  drop sumTcttot temp1

-> 

->  gen temp1=pop if msa!=9999
(9 missing values generated)

->  egen sumpop=sum(temp1), by(period)

->  gen shpop=pop/sumpop if msa!=9999
(9 missing values generated)

->  drop sumpop temp1

. for var T* pop: gen hhiX=shX^2 if msa!=9999;

->  gen hhiTct00=shTct00^2 if msa!=9999
(9 missing values generated)

->  gen hhiTct10=shTct10^2 if msa!=9999
(9 missing values generated)

->  gen hhiTct80=shTct80^2 if msa!=9999
(9 missing values generated)

->  gen hhiTcttot=shTcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhipop=shpop^2 if msa!=9999
(9 missing values generated)

. for var T*: gen egX=(shX-shpop)^2 if msa!=9999;

->  gen egTct00=(shTct00-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egTct10=(shTct10-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egTct80=(shTct80-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egTcttot=(shTcttot-shpop)^2 if msa!=9999
(9 missing values generated)

. for var hhi* eg*: replace X=. if msa==9999;

->  replace hhiTct00=. if msa==9999
(0 real changes made)

->  replace hhiTct10=. if msa==9999
(0 real changes made)

->  replace hhiTct80=. if msa==9999
(0 real changes made)

->  replace hhiTcttot=. if msa==9999
(0 real changes made)

->  replace hhipop=. if msa==9999
(0 real changes made)

->  replace egTct00=. if msa==9999
(0 real changes made)

->  replace egTct10=. if msa==9999
(0 real changes made)

->  replace egTct80=. if msa==9999
(0 real changes made)

->  replace egTcttot=. if msa==9999
(0 real changes made)

. collapse (sum) T* tab* hhi* eg*, by(period) fast;

. for var eg*: replace X=X/(1-hhipop);

->  replace egTct00=egTct00/(1-hhipop)
(9 real changes made)

->  replace egTct10=egTct10/(1-hhipop)
(9 real changes made)

->  replace egTct80=egTct80/(1-hhipop)
(9 real changes made)

->  replace egTcttot=egTcttot/(1-hhipop)
(9 real changes made)

. for any 00 10 80: 
> \ egen temp1=rsum(tabTctX*) 
> \ replace tabTctX1=tabTctX1/temp1 
> \ replace tabTctX2=tabTctX2/temp1 
> \ replace tabTctX3=tabTctX3/temp1 
> \ replace tabTctX4=tabTctX4/temp1 
> \ drop temp1;

-> 

->  egen temp1=rsum(tabTct00*)

->  replace tabTct001=tabTct001/temp1
(9 real changes made)

->  replace tabTct002=tabTct002/temp1
(9 real changes made)

->  replace tabTct003=tabTct003/temp1
(9 real changes made)

->  replace tabTct004=tabTct004/temp1
(9 real changes made)

->  drop temp1

-> 

->  egen temp1=rsum(tabTct10*)

->  replace tabTct101=tabTct101/temp1
(9 real changes made)

->  replace tabTct102=tabTct102/temp1
(9 real changes made)

->  replace tabTct103=tabTct103/temp1
(9 real changes made)

->  replace tabTct104=tabTct104/temp1
(9 real changes made)

->  drop temp1

-> 

->  egen temp1=rsum(tabTct80*)

->  replace tabTct801=tabTct801/temp1
(9 real changes made)

->  replace tabTct802=tabTct802/temp1
(9 real changes made)

->  replace tabTct803=tabTct803/temp1
(9 real changes made)

->  replace tabTct804=tabTct804/temp1
(9 real changes made)

->  drop temp1

. for any 00 10 80: gen shX=100*TctX/Tcttot;

->  gen sh00=100*Tct00/Tcttot

->  gen sh10=100*Tct10/Tcttot

->  gen sh80=100*Tct80/Tcttot

. format tab* eg* hhi* %4.3f;

.  format sh* %3.2f;

.  list period tabTct00*, clean noobs;

    period   tabT~001   tabT~002   tabT~003   tabT~004  
      1975      0.108      0.310      0.463      0.119  
      1980      0.115      0.288      0.475      0.121  
      1985      0.126      0.264      0.492      0.118  
      1990      0.138      0.243      0.504      0.116  
      1995      0.175      0.217      0.502      0.106  
      2000      0.201      0.202      0.495      0.102  
      2005      0.216      0.200      0.492      0.092  
      2010      0.227      0.195      0.492      0.087  
      2015      0.228      0.195      0.490      0.087  

. list period tabTct10*, clean noobs;

    period   tabT~101   tabT~102   tabT~103   tabT~104  
      1975      0.122      0.377      0.423      0.078  
      1980      0.141      0.341      0.443      0.075  
      1985      0.155      0.335      0.438      0.073  
      1990      0.182      0.297      0.453      0.067  
      1995      0.249      0.252      0.441      0.058  
      2000      0.280      0.231      0.433      0.057  
      2005      0.312      0.223      0.408      0.056  
      2010      0.333      0.209      0.404      0.055  
      2015      0.348      0.197      0.402      0.052  

. list period tabTct80*, clean noobs;

    period   tabT~801   tabT~802   tabT~803   tabT~804  
      1975      0.196      0.322      0.410      0.072  
      1980      0.217      0.294      0.429      0.060  
      1985      0.258      0.262      0.420      0.060  
      1990      0.307      0.236      0.407      0.050  
      1995      0.389      0.205      0.367      0.039  
      2000      0.422      0.183      0.361      0.035  
      2005      0.442      0.181      0.343      0.034  
      2010      0.475      0.172      0.319      0.034  
      2015      0.475      0.171      0.320      0.035  

. list period sh*, clean noobs;

    period    sh00    sh10    sh80  
      1975   79.68   17.50    2.82  
      1980   77.94   17.73    4.33  
      1985   76.85   16.95    6.20  
      1990   71.65   17.83   10.52  
      1995   61.31   17.92   20.77  
      2000   55.87   17.34   26.79  
      2005   48.36   17.56   34.09  
      2010   45.62   17.59   36.80  
      2015   45.04   16.97   37.99  

. list period eg*, clean noobs;

    period   egTct00   egTct10   egTct80   egTcttot  
      1975     0.003     0.013     0.009      0.003  
      1980     0.003     0.011     0.008      0.003  
      1985     0.003     0.010     0.013      0.003  
      1990     0.004     0.009     0.020      0.005  
      1995     0.008     0.013     0.040      0.013  
      2000     0.014     0.019     0.045      0.020  
      2005     0.015     0.024     0.049      0.025  
      2010     0.016     0.028     0.068      0.032  
      2015     0.015     0.029     0.071      0.033  

. *********************************;
. *** Core AI Analysis          ***;
. *********************************;
. use if software_ai!=. using patent-spatial-final1, clear;

. drop gyear ayear num_claims backward forward fw_selfcite originality generality dENG-dVNM uspc*;

. * Organize patents and institutions;
. gen Tcttot=1;

.  gen Tctsw=software_ai;

.  gen Tctnsw=1-software_ai;

. for any cttot ctsw ctnsw: gen IX=TX if ind==1 \ gen UX=TX if univ==1 \ gen GX=TX if gov==1 \ gen NX=TX if (ind==0 & gov==0 & univ==0
> );

->  gen Icttot=Tcttot if ind==1
(680,929 missing values generated)

->  gen Ucttot=Tcttot if univ==1
(3,360,530 missing values generated)

->  gen Gcttot=Tcttot if gov==1
(3,456,573 missing values generated)

->  gen Ncttot=Tcttot if (ind==0 & gov==0 & univ==0)
(2,975,159 missing values generated)

->  gen Ictsw=Tctsw if ind==1
(680,929 missing values generated)

->  gen Uctsw=Tctsw if univ==1
(3,360,530 missing values generated)

->  gen Gctsw=Tctsw if gov==1
(3,456,573 missing values generated)

->  gen Nctsw=Tctsw if (ind==0 & gov==0 & univ==0)
(2,975,159 missing values generated)

->  gen Ictnsw=Tctnsw if ind==1
(680,929 missing values generated)

->  gen Uctnsw=Tctnsw if univ==1
(3,360,530 missing values generated)

->  gen Gctnsw=Tctnsw if gov==1
(3,456,573 missing values generated)

->  gen Nctnsw=Tctnsw if (ind==0 & gov==0 & univ==0)
(2,975,159 missing values generated)

. for any cttot ctsw ctnsw: gen C1X=TX if (nber_cat==2 | nber_cat==4) \ gen C2X=TX if (nber_cat==1 | nber_cat==3) \ gen C3X=TX if (nbe
> r_cat==5 | nber_cat==6);

->  gen C1cttot=Tcttot if (nber_cat==2 | nber_cat==4)
(1,933,999 missing values generated)

->  gen C2cttot=Tcttot if (nber_cat==1 | nber_cat==3)
(2,625,771 missing values generated)

->  gen C3cttot=Tcttot if (nber_cat==5 | nber_cat==6)
(2,433,120 missing values generated)

->  gen C1ctsw=Tctsw if (nber_cat==2 | nber_cat==4)
(1,933,999 missing values generated)

->  gen C2ctsw=Tctsw if (nber_cat==1 | nber_cat==3)
(2,625,771 missing values generated)

->  gen C3ctsw=Tctsw if (nber_cat==5 | nber_cat==6)
(2,433,120 missing values generated)

->  gen C1ctnsw=Tctnsw if (nber_cat==2 | nber_cat==4)
(1,933,999 missing values generated)

->  gen C2ctnsw=Tctnsw if (nber_cat==1 | nber_cat==3)
(2,625,771 missing values generated)

->  gen C3ctnsw=Tctnsw if (nber_cat==5 | nber_cat==6)
(2,433,120 missing values generated)

. for num 1/6: gen ZXctsw=Tctsw if nber_cat==X \ gen ZXctnsw=Tctnsw if nber_cat==X;

->  gen Z1ctsw=Tctsw if nber_cat==1
(3,067,822 missing values generated)

->  gen Z1ctnsw=Tctnsw if nber_cat==1
(3,067,822 missing values generated)

->  gen Z2ctsw=Tctsw if nber_cat==2
(2,533,546 missing values generated)

->  gen Z2ctnsw=Tctnsw if nber_cat==2
(2,533,546 missing values generated)

->  gen Z3ctsw=Tctsw if nber_cat==3
(3,054,394 missing values generated)

->  gen Z3ctnsw=Tctnsw if nber_cat==3
(3,054,394 missing values generated)

->  gen Z4ctsw=Tctsw if nber_cat==4
(2,896,898 missing values generated)

->  gen Z4ctnsw=Tctnsw if nber_cat==4
(2,896,898 missing values generated)

->  gen Z5ctsw=Tctsw if nber_cat==5
(3,016,172 missing values generated)

->  gen Z5ctnsw=Tctnsw if nber_cat==5
(3,016,172 missing values generated)

->  gen Z6ctsw=Tctsw if nber_cat==6
(2,913,393 missing values generated)

->  gen Z6ctnsw=Tctnsw if nber_cat==6
(2,913,393 missing values generated)

. * Collapse on MSA-period cells and merge population data;
. * Prepare a zero-valued observation for 7000 in 1980;
. * Fix pop min for early years of 380 (Anchorage AK) and 3320 (Honolulu HI);
. collapse (sum) T* I* U* G* N* C* Z* (mean) cluster, by(msa period) fast;

. sort msa period;

.  merge msa period using period_population_msa;
(note: you are using old merge syntax; see [D] merge for new syntax)

. tab _m;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |          8        0.32        0.32
          2 |          1        0.04        0.35
          3 |      2,529       99.65      100.00
------------+-----------------------------------
      Total |      2,538      100.00

.  table msa _m if _m!=3;

----------------------
          |   _merge  
      msa |    1     2
----------+-----------
      380 |    3      
     3320 |    5      
     7000 |          1
----------------------

.  ren pop pop;

.  for var T* I* U* G* N* C* Z*: replace X=0 if _m==2;

->  replace Tcttot=0 if _m==2
(1 real change made)

->  replace Tctsw=0 if _m==2
(1 real change made)

->  replace Tctnsw=0 if _m==2
(1 real change made)

->  replace Icttot=0 if _m==2
(1 real change made)

->  replace Ictsw=0 if _m==2
(1 real change made)

->  replace Ictnsw=0 if _m==2
(1 real change made)

->  replace Ucttot=0 if _m==2
(1 real change made)

->  replace Uctsw=0 if _m==2
(1 real change made)

->  replace Uctnsw=0 if _m==2
(1 real change made)

->  replace Gcttot=0 if _m==2
(1 real change made)

->  replace Gctsw=0 if _m==2
(1 real change made)

->  replace Gctnsw=0 if _m==2
(1 real change made)

->  replace Ncttot=0 if _m==2
(1 real change made)

->  replace Nctsw=0 if _m==2
(1 real change made)

->  replace Nctnsw=0 if _m==2
(1 real change made)

->  replace C1cttot=0 if _m==2
(1 real change made)

->  replace C2cttot=0 if _m==2
(1 real change made)

->  replace C3cttot=0 if _m==2
(1 real change made)

->  replace C1ctsw=0 if _m==2
(1 real change made)

->  replace C2ctsw=0 if _m==2
(1 real change made)

->  replace C3ctsw=0 if _m==2
(1 real change made)

->  replace C1ctnsw=0 if _m==2
(1 real change made)

->  replace C2ctnsw=0 if _m==2
(1 real change made)

->  replace C3ctnsw=0 if _m==2
(1 real change made)

->  replace Z1ctsw=0 if _m==2
(1 real change made)

->  replace Z1ctnsw=0 if _m==2
(1 real change made)

->  replace Z2ctsw=0 if _m==2
(1 real change made)

->  replace Z2ctnsw=0 if _m==2
(1 real change made)

->  replace Z3ctsw=0 if _m==2
(1 real change made)

->  replace Z3ctnsw=0 if _m==2
(1 real change made)

->  replace Z4ctsw=0 if _m==2
(1 real change made)

->  replace Z4ctnsw=0 if _m==2
(1 real change made)

->  replace Z5ctsw=0 if _m==2
(1 real change made)

->  replace Z5ctnsw=0 if _m==2
(1 real change made)

->  replace Z6ctsw=0 if _m==2
(1 real change made)

->  replace Z6ctnsw=0 if _m==2
(1 real change made)

. egen temp1=min(pop), by(msa);

.  replace pop=temp1 if _m==1;
(8 real changes made)

.  drop _m temp1;

. * Generate HHI and EG components and collapse;
. for var T*: gen tabX1=X if cluster==1 \ gen tabX2=X if cluster==2 \ gen tabX3=X if cluster==3 \ gen tabX4=X if cluster==4;

->  gen tabTcttot1=Tcttot if cluster==1
(2,484 missing values generated)

->  gen tabTcttot2=Tcttot if cluster==2
(2,493 missing values generated)

->  gen tabTcttot3=Tcttot if cluster==3
(109 missing values generated)

->  gen tabTcttot4=Tcttot if cluster==4
(2,529 missing values generated)

->  gen tabTctsw1=Tctsw if cluster==1
(2,484 missing values generated)

->  gen tabTctsw2=Tctsw if cluster==2
(2,493 missing values generated)

->  gen tabTctsw3=Tctsw if cluster==3
(109 missing values generated)

->  gen tabTctsw4=Tctsw if cluster==4
(2,529 missing values generated)

->  gen tabTctnsw1=Tctnsw if cluster==1
(2,484 missing values generated)

->  gen tabTctnsw2=Tctnsw if cluster==2
(2,493 missing values generated)

->  gen tabTctnsw3=Tctnsw if cluster==3
(109 missing values generated)

->  gen tabTctnsw4=Tctnsw if cluster==4
(2,529 missing values generated)

. for var T* I* U* G* N* C* pop:
> \ gen temp1=X if msa!=9999 \ egen sumX=sum(temp1), by(period) \ gen shX=X/sumX if msa!=9999  \ drop sumX temp1;

-> 

->  gen temp1=Tcttot if msa!=9999
(9 missing values generated)

->  egen sumTcttot=sum(temp1), by(period)

->  gen shTcttot=Tcttot/sumTcttot if msa!=9999
(9 missing values generated)

->  drop sumTcttot temp1

-> 

->  gen temp1=Tctsw if msa!=9999
(9 missing values generated)

->  egen sumTctsw=sum(temp1), by(period)

->  gen shTctsw=Tctsw/sumTctsw if msa!=9999
(9 missing values generated)

->  drop sumTctsw temp1

-> 

->  gen temp1=Tctnsw if msa!=9999
(9 missing values generated)

->  egen sumTctnsw=sum(temp1), by(period)

->  gen shTctnsw=Tctnsw/sumTctnsw if msa!=9999
(9 missing values generated)

->  drop sumTctnsw temp1

-> 

->  gen temp1=Icttot if msa!=9999
(9 missing values generated)

->  egen sumIcttot=sum(temp1), by(period)

->  gen shIcttot=Icttot/sumIcttot if msa!=9999
(9 missing values generated)

->  drop sumIcttot temp1

-> 

->  gen temp1=Ictsw if msa!=9999
(9 missing values generated)

->  egen sumIctsw=sum(temp1), by(period)

->  gen shIctsw=Ictsw/sumIctsw if msa!=9999
(9 missing values generated)

->  drop sumIctsw temp1

-> 

->  gen temp1=Ictnsw if msa!=9999
(9 missing values generated)

->  egen sumIctnsw=sum(temp1), by(period)

->  gen shIctnsw=Ictnsw/sumIctnsw if msa!=9999
(9 missing values generated)

->  drop sumIctnsw temp1

-> 

->  gen temp1=Ucttot if msa!=9999
(9 missing values generated)

->  egen sumUcttot=sum(temp1), by(period)

->  gen shUcttot=Ucttot/sumUcttot if msa!=9999
(9 missing values generated)

->  drop sumUcttot temp1

-> 

->  gen temp1=Uctsw if msa!=9999
(9 missing values generated)

->  egen sumUctsw=sum(temp1), by(period)

->  gen shUctsw=Uctsw/sumUctsw if msa!=9999
(9 missing values generated)

->  drop sumUctsw temp1

-> 

->  gen temp1=Uctnsw if msa!=9999
(9 missing values generated)

->  egen sumUctnsw=sum(temp1), by(period)

->  gen shUctnsw=Uctnsw/sumUctnsw if msa!=9999
(9 missing values generated)

->  drop sumUctnsw temp1

-> 

->  gen temp1=Gcttot if msa!=9999
(9 missing values generated)

->  egen sumGcttot=sum(temp1), by(period)

->  gen shGcttot=Gcttot/sumGcttot if msa!=9999
(9 missing values generated)

->  drop sumGcttot temp1

-> 

->  gen temp1=Gctsw if msa!=9999
(9 missing values generated)

->  egen sumGctsw=sum(temp1), by(period)

->  gen shGctsw=Gctsw/sumGctsw if msa!=9999
(9 missing values generated)

->  drop sumGctsw temp1

-> 

->  gen temp1=Gctnsw if msa!=9999
(9 missing values generated)

->  egen sumGctnsw=sum(temp1), by(period)

->  gen shGctnsw=Gctnsw/sumGctnsw if msa!=9999
(9 missing values generated)

->  drop sumGctnsw temp1

-> 

->  gen temp1=Ncttot if msa!=9999
(9 missing values generated)

->  egen sumNcttot=sum(temp1), by(period)

->  gen shNcttot=Ncttot/sumNcttot if msa!=9999
(9 missing values generated)

->  drop sumNcttot temp1

-> 

->  gen temp1=Nctsw if msa!=9999
(9 missing values generated)

->  egen sumNctsw=sum(temp1), by(period)

->  gen shNctsw=Nctsw/sumNctsw if msa!=9999
(9 missing values generated)

->  drop sumNctsw temp1

-> 

->  gen temp1=Nctnsw if msa!=9999
(9 missing values generated)

->  egen sumNctnsw=sum(temp1), by(period)

->  gen shNctnsw=Nctnsw/sumNctnsw if msa!=9999
(9 missing values generated)

->  drop sumNctnsw temp1

-> 

->  gen temp1=C1cttot if msa!=9999
(9 missing values generated)

->  egen sumC1cttot=sum(temp1), by(period)

->  gen shC1cttot=C1cttot/sumC1cttot if msa!=9999
(9 missing values generated)

->  drop sumC1cttot temp1

-> 

->  gen temp1=C2cttot if msa!=9999
(9 missing values generated)

->  egen sumC2cttot=sum(temp1), by(period)

->  gen shC2cttot=C2cttot/sumC2cttot if msa!=9999
(9 missing values generated)

->  drop sumC2cttot temp1

-> 

->  gen temp1=C3cttot if msa!=9999
(9 missing values generated)

->  egen sumC3cttot=sum(temp1), by(period)

->  gen shC3cttot=C3cttot/sumC3cttot if msa!=9999
(9 missing values generated)

->  drop sumC3cttot temp1

-> 

->  gen temp1=C1ctsw if msa!=9999
(9 missing values generated)

->  egen sumC1ctsw=sum(temp1), by(period)

->  gen shC1ctsw=C1ctsw/sumC1ctsw if msa!=9999
(9 missing values generated)

->  drop sumC1ctsw temp1

-> 

->  gen temp1=C2ctsw if msa!=9999
(9 missing values generated)

->  egen sumC2ctsw=sum(temp1), by(period)

->  gen shC2ctsw=C2ctsw/sumC2ctsw if msa!=9999
(9 missing values generated)

->  drop sumC2ctsw temp1

-> 

->  gen temp1=C3ctsw if msa!=9999
(9 missing values generated)

->  egen sumC3ctsw=sum(temp1), by(period)

->  gen shC3ctsw=C3ctsw/sumC3ctsw if msa!=9999
(9 missing values generated)

->  drop sumC3ctsw temp1

-> 

->  gen temp1=C1ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC1ctnsw=sum(temp1), by(period)

->  gen shC1ctnsw=C1ctnsw/sumC1ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC1ctnsw temp1

-> 

->  gen temp1=C2ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC2ctnsw=sum(temp1), by(period)

->  gen shC2ctnsw=C2ctnsw/sumC2ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC2ctnsw temp1

-> 

->  gen temp1=C3ctnsw if msa!=9999
(9 missing values generated)

->  egen sumC3ctnsw=sum(temp1), by(period)

->  gen shC3ctnsw=C3ctnsw/sumC3ctnsw if msa!=9999
(9 missing values generated)

->  drop sumC3ctnsw temp1

-> 

->  gen temp1=pop if msa!=9999
(9 missing values generated)

->  egen sumpop=sum(temp1), by(period)

->  gen shpop=pop/sumpop if msa!=9999
(9 missing values generated)

->  drop sumpop temp1

. for var T* I* U* G* N* C* pop: gen hhiX=shX^2 if msa!=9999;

->  gen hhiTcttot=shTcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiTctsw=shTctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiTctnsw=shTctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiIcttot=shIcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiIctsw=shIctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiIctnsw=shIctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiUcttot=shUcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiUctsw=shUctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiUctnsw=shUctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiGcttot=shGcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiGctsw=shGctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiGctnsw=shGctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiNcttot=shNcttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiNctsw=shNctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiNctnsw=shNctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC1cttot=shC1cttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiC2cttot=shC2cttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiC3cttot=shC3cttot^2 if msa!=9999
(9 missing values generated)

->  gen hhiC1ctsw=shC1ctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC2ctsw=shC2ctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC3ctsw=shC3ctsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC1ctnsw=shC1ctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC2ctnsw=shC2ctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhiC3ctnsw=shC3ctnsw^2 if msa!=9999
(9 missing values generated)

->  gen hhipop=shpop^2 if msa!=9999
(9 missing values generated)

. for var T* I* U* G* N* C*: gen egX=(shX-shpop)^2 if msa!=9999;

->  gen egTcttot=(shTcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egTctsw=(shTctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egTctnsw=(shTctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egIcttot=(shIcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egIctsw=(shIctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egIctnsw=(shIctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egUcttot=(shUcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egUctsw=(shUctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egUctnsw=(shUctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egGcttot=(shGcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egGctsw=(shGctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egGctnsw=(shGctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egNcttot=(shNcttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egNctsw=(shNctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egNctnsw=(shNctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC1cttot=(shC1cttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC2cttot=(shC2cttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC3cttot=(shC3cttot-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC1ctsw=(shC1ctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC2ctsw=(shC2ctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC3ctsw=(shC3ctsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC1ctnsw=(shC1ctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC2ctnsw=(shC2ctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

->  gen egC3ctnsw=(shC3ctnsw-shpop)^2 if msa!=9999
(9 missing values generated)

. for var hhi* eg*: replace X=. if msa==9999;

->  replace hhiTcttot=. if msa==9999
(0 real changes made)

->  replace hhiTctsw=. if msa==9999
(0 real changes made)

->  replace hhiTctnsw=. if msa==9999
(0 real changes made)

->  replace hhiIcttot=. if msa==9999
(0 real changes made)

->  replace hhiIctsw=. if msa==9999
(0 real changes made)

->  replace hhiIctnsw=. if msa==9999
(0 real changes made)

->  replace hhiUcttot=. if msa==9999
(0 real changes made)

->  replace hhiUctsw=. if msa==9999
(0 real changes made)

->  replace hhiUctnsw=. if msa==9999
(0 real changes made)

->  replace hhiGcttot=. if msa==9999
(0 real changes made)

->  replace hhiGctsw=. if msa==9999
(0 real changes made)

->  replace hhiGctnsw=. if msa==9999
(0 real changes made)

->  replace hhiNcttot=. if msa==9999
(0 real changes made)

->  replace hhiNctsw=. if msa==9999
(0 real changes made)

->  replace hhiNctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC1cttot=. if msa==9999
(0 real changes made)

->  replace hhiC2cttot=. if msa==9999
(0 real changes made)

->  replace hhiC3cttot=. if msa==9999
(0 real changes made)

->  replace hhiC1ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC2ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC3ctsw=. if msa==9999
(0 real changes made)

->  replace hhiC1ctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC2ctnsw=. if msa==9999
(0 real changes made)

->  replace hhiC3ctnsw=. if msa==9999
(0 real changes made)

->  replace hhipop=. if msa==9999
(0 real changes made)

->  replace egTcttot=. if msa==9999
(0 real changes made)

->  replace egTctsw=. if msa==9999
(0 real changes made)

->  replace egTctnsw=. if msa==9999
(0 real changes made)

->  replace egIcttot=. if msa==9999
(0 real changes made)

->  replace egIctsw=. if msa==9999
(0 real changes made)

->  replace egIctnsw=. if msa==9999
(0 real changes made)

->  replace egUcttot=. if msa==9999
(0 real changes made)

->  replace egUctsw=. if msa==9999
(0 real changes made)

->  replace egUctnsw=. if msa==9999
(0 real changes made)

->  replace egGcttot=. if msa==9999
(0 real changes made)

->  replace egGctsw=. if msa==9999
(0 real changes made)

->  replace egGctnsw=. if msa==9999
(0 real changes made)

->  replace egNcttot=. if msa==9999
(0 real changes made)

->  replace egNctsw=. if msa==9999
(0 real changes made)

->  replace egNctnsw=. if msa==9999
(0 real changes made)

->  replace egC1cttot=. if msa==9999
(0 real changes made)

->  replace egC2cttot=. if msa==9999
(0 real changes made)

->  replace egC3cttot=. if msa==9999
(0 real changes made)

->  replace egC1ctsw=. if msa==9999
(0 real changes made)

->  replace egC2ctsw=. if msa==9999
(0 real changes made)

->  replace egC3ctsw=. if msa==9999
(0 real changes made)

->  replace egC1ctnsw=. if msa==9999
(0 real changes made)

->  replace egC2ctnsw=. if msa==9999
(0 real changes made)

->  replace egC3ctnsw=. if msa==9999
(0 real changes made)

. collapse (sum) T* I* U* G* N* C* Z* tab* hhi* eg*, by(period) fast;

. for var tabTcttot*: gen rawX=X \ replace X=X/Tcttot;

->  gen rawtabTcttot1=tabTcttot1

->  replace tabTcttot1=tabTcttot1/Tcttot
(9 real changes made)

->  gen rawtabTcttot2=tabTcttot2

->  replace tabTcttot2=tabTcttot2/Tcttot
(9 real changes made)

->  gen rawtabTcttot3=tabTcttot3

->  replace tabTcttot3=tabTcttot3/Tcttot
(9 real changes made)

->  gen rawtabTcttot4=tabTcttot4

->  replace tabTcttot4=tabTcttot4/Tcttot
(9 real changes made)

. for var tabTctsw*: gen rawX=X \ replace X=X/Tctsw;

->  gen rawtabTctsw1=tabTctsw1

->  replace tabTctsw1=tabTctsw1/Tctsw
(9 real changes made)

->  gen rawtabTctsw2=tabTctsw2

->  replace tabTctsw2=tabTctsw2/Tctsw
(9 real changes made)

->  gen rawtabTctsw3=tabTctsw3

->  replace tabTctsw3=tabTctsw3/Tctsw
(9 real changes made)

->  gen rawtabTctsw4=tabTctsw4

->  replace tabTctsw4=tabTctsw4/Tctsw
(9 real changes made)

. for var tabTctnsw*: gen rawX=X \ replace X=X/Tctnsw;

->  gen rawtabTctnsw1=tabTctnsw1

->  replace tabTctnsw1=tabTctnsw1/Tctnsw
(9 real changes made)

->  gen rawtabTctnsw2=tabTctnsw2

->  replace tabTctnsw2=tabTctnsw2/Tctnsw
(9 real changes made)

->  gen rawtabTctnsw3=tabTctnsw3

->  replace tabTctnsw3=tabTctnsw3/Tctnsw
(9 real changes made)

->  gen rawtabTctnsw4=tabTctnsw4

->  replace tabTctnsw4=tabTctnsw4/Tctnsw
(9 real changes made)

. for var eg*: replace X=X/(1-hhipop);

->  replace egTcttot=egTcttot/(1-hhipop)
(9 real changes made)

->  replace egTctsw=egTctsw/(1-hhipop)
(9 real changes made)

->  replace egTctnsw=egTctnsw/(1-hhipop)
(9 real changes made)

->  replace egIcttot=egIcttot/(1-hhipop)
(9 real changes made)

->  replace egIctsw=egIctsw/(1-hhipop)
(9 real changes made)

->  replace egIctnsw=egIctnsw/(1-hhipop)
(9 real changes made)

->  replace egUcttot=egUcttot/(1-hhipop)
(9 real changes made)

->  replace egUctsw=egUctsw/(1-hhipop)
(9 real changes made)

->  replace egUctnsw=egUctnsw/(1-hhipop)
(9 real changes made)

->  replace egGcttot=egGcttot/(1-hhipop)
(9 real changes made)

->  replace egGctsw=egGctsw/(1-hhipop)
(9 real changes made)

->  replace egGctnsw=egGctnsw/(1-hhipop)
(9 real changes made)

->  replace egNcttot=egNcttot/(1-hhipop)
(9 real changes made)

->  replace egNctsw=egNctsw/(1-hhipop)
(9 real changes made)

->  replace egNctnsw=egNctnsw/(1-hhipop)
(9 real changes made)

->  replace egC1cttot=egC1cttot/(1-hhipop)
(9 real changes made)

->  replace egC2cttot=egC2cttot/(1-hhipop)
(9 real changes made)

->  replace egC3cttot=egC3cttot/(1-hhipop)
(9 real changes made)

->  replace egC1ctsw=egC1ctsw/(1-hhipop)
(9 real changes made)

->  replace egC2ctsw=egC2ctsw/(1-hhipop)
(9 real changes made)

->  replace egC3ctsw=egC3ctsw/(1-hhipop)
(9 real changes made)

->  replace egC1ctnsw=egC1ctnsw/(1-hhipop)
(9 real changes made)

->  replace egC2ctnsw=egC2ctnsw/(1-hhipop)
(9 real changes made)

->  replace egC3ctnsw=egC3ctnsw/(1-hhipop)
(9 real changes made)

. for any T I U G N C1 C2 C3: gen shswX=100*Xctsw/Xcttot;

->  gen shswT=100*Tctsw/Tcttot

->  gen shswI=100*Ictsw/Icttot

->  gen shswU=100*Uctsw/Ucttot

->  gen shswG=100*Gctsw/Gcttot

->  gen shswN=100*Nctsw/Ncttot

->  gen shswC1=100*C1ctsw/C1cttot

->  gen shswC2=100*C2ctsw/C2cttot

->  gen shswC3=100*C3ctsw/C3cttot

. format tab* eg* hhi* %4.3f;

.  format sh* %3.2f;

.  format raw* %8.0f;

.  * Table S10c - Equivalent to Figure 2 & Table S2;
. for any tot sw nsw:
> list period tabTctX*, clean noobs;

->  list period tabTcttot*, clean noobs

    period   tabTc~t1   tabTc~t2   tabTc~t3   tabTc~t4  
      1975      0.113      0.322      0.455      0.110  
      1980      0.124      0.298      0.468      0.110  
      1985      0.139      0.276      0.478      0.107  
      1990      0.163      0.252      0.485      0.100  
      1995      0.233      0.221      0.463      0.084  
      2000      0.274      0.202      0.448      0.076  
      2005      0.310      0.198      0.427      0.066  
      2010      0.337      0.189      0.413      0.062  
      2015      0.342      0.186      0.410      0.061  

->  list period tabTctsw*, clean noobs

    period   tab~tsw1   tab~tsw2   tab~tsw3   tab~tsw4  
      1975      0.183      0.317      0.425      0.076  
      1980      0.211      0.288      0.442      0.058  
      1985      0.263      0.254      0.420      0.063  
      1990      0.319      0.217      0.411      0.053  
      1995      0.426      0.192      0.349      0.033  
      2000      0.452      0.174      0.344      0.031  
      2005      0.471      0.178      0.326      0.025  
      2010      0.505      0.173      0.297      0.024  
      2015      0.502      0.172      0.301      0.026  

->  list period tabTctnsw*, clean noobs

    period   tab~nsw1   tab~nsw2   tab~nsw3   tab~nsw4  
      1975      0.112      0.322      0.455      0.111  
      1980      0.123      0.298      0.468      0.111  
      1985      0.136      0.276      0.480      0.108  
      1990      0.156      0.254      0.488      0.102  
      1995      0.213      0.223      0.475      0.089  
      2000      0.247      0.206      0.464      0.083  
      2005      0.275      0.202      0.448      0.074  
      2010      0.296      0.193      0.440      0.071  
      2015      0.302      0.190      0.438      0.070  

. * Table S11b - Equivalent to Table S3;
. for any T:
> list period Xcttot Xctsw shswX hhiXcttot hhiXctsw hhiXctnsw egXcttot egXctsw egXctnsw, clean noobs;

->  list period Tcttot Tctsw shswT hhiTcttot hhiTctsw hhiTctnsw egTcttot egTctsw egTctnsw, clean noobs

    period   Tcttot    Tctsw   shswT   hhiTct~t   hhiTctsw   hhiT~nsw   egTcttot   egTctsw   egTctnsw  
      1975   197893     1778    0.90      0.041      0.049      0.040      0.003     0.009      0.003  
      1980   181184     2726    1.50      0.037      0.044      0.037      0.003     0.008      0.003  
      1985   214436     5342    2.49      0.034      0.047      0.034      0.003     0.014      0.003  
      1990   293473    12999    4.43      0.032      0.058      0.032      0.005     0.027      0.004  
      1995   443348    40893    9.22      0.039      0.083      0.036      0.013     0.053      0.010  
      2000   526503    68801   13.07      0.045      0.083      0.041      0.020     0.056      0.017  
      2005   515238    90882   17.64      0.050      0.089      0.044      0.025     0.061      0.019  
      2010   630314   121650   19.30      0.057      0.113      0.048      0.032     0.083      0.023  
      2015   494056    99931   20.23      0.058      0.119      0.048      0.033     0.089      0.024  

. *** End of program;
. log close;
      name:  <unnamed>
       log:  D:\Dropbox\zworking\r-patent\paper-trends\replication\patent-spatial-replication.log
  log type:  text
 closed on:  28 Oct 2021, 08:04:26
--------------------------------------------------------------------------------------------------------------------------------------
